- Education and Science»
How to Add and Delete Users on Centos
How to add user on Centos
How to Add a User on CentOS 6
To add a new user in CentOS, use the adduser command, replacing the “newuser” with your preferred username.
sudo adduser newuser
Follow up by providing the user with a new password, typing and confirming the new password when prompted:
sudo newuser passwd
Congratulations—you have just added a new user and their password. You can log out of the root user by typing exit and then logging back in with the new username and password.
How to Grant a User Root Privileges
As mentioned earlier, you are much better off using a user with root privileges. You can create the sudo user by opening the sudoers file with this command:
You will find the section to make the user privilege modifications at the bottom of the file. Type “a” to start inserting text. Adding the user’s name and the same permissions as root under the the user privilege specification will grant them the sudo privileges.
## Allow root to run any commands anywhere root ALL=(ALL) ALL newuser ALL=(ALL) ALL
Save and Exit the file by press “shift” ZZ.
How to Delete a User
Should you find that you find that you no longer want to have a specific user on the virtual private server you can delete them with a single command.
sudo userdel newuser
You can add the flag “-r” to the command if you would like to simultaneously remove the users’s home directory and files.
sudo userdel -r newuser