Write for DigitalOcean You get paid, we donate to tech non-profits. When you first start using a fresh Linux server, adding and removing users is one of the most basic tasks that you should know how to do. When you create a new server, you are only given the root account by default. It is almost always a better idea to add an additional, unprivileged user to do common tasks.
You should also create additional accounts for any other users that need access to your server. Each user should have an additional account so that their activities can be monitored and managed. You can still acquire administrative privileges, when needed, through a mechanism called sudo. In this guide, we will cover how to create user accounts, assign sudo privileges, and delete users on a CentOS 7 server. If you are signed in as the root user, you can create a new user at any time by typing:.
If you are signed in as a non-root user who has been given sudo privileges, as demonstrated in the next section of this tutorial, you can add a new user by typing:. To do so, use the passwd command:. Note: Remember to add sudo ahead of the command if you are signed in as a non-root user with sudo privileges. You will be prompted to type in the password twice to confirm it. You can also subscribe without commenting.
This site uses Akismet to reduce spam. Learn how your comment data is processed. Creates and populates a home directory for the new user. Sets permissions and ownerships to the home directory. Useradd Command Syntax. Part I — 10 Basic Usage of useradd Commands. If you liked this article, then do subscribe to email alerts for Linux tutorials.
If you have any questions or doubts? Related Posts. Section 3. Thanks, nice tips Reply. Hi, Can you please tell us to how to create a user with password in single command line on Debian Thank you.
Yogesh Reply. Yogesh, I hope this following command will help you to add user and password with one single command. Thanks again for your response. Thanks Reply. Any further ideas?
The manpage can be shown with this command:. If the user account is no longer needed, you can delete it using the deluser command line tool. To delete the user, without deleting the user files, run:. If the user was granted sudo privileges it will be removed the wheel group, as well as from any other groups the user was a member of. In this tutorial, you learned how to add and remove users in CentOS. The same commands apply for any other Linux distribution.
If you have any question or feedback feel free to leave a comment. Your email address will not be published. Please input characters displayed above.
In this example, we will see how to create user in centos 7 with a custom home directory. As I mentioned in the beginning of the tutorial you can also use the user manager graphical interface if you are using CentOS 7 Desktop.
From there also you can add new users to the CentOS 7 System.
0コメント