This time we want to show you how to add a user on CentOS 6 VPS and properly grant root privileges. When you first get your VPS from VelociHOST, you will be provided with the root user and its corresponding password. While this provides the availability to make any changes to the operating system, it is not a good practice to use it on a evey day basis and for every basic tasks.

That is why we'll show you how to add a user while conserving root privileges for a more secure way of working with your VPS on an day by day basis.

Add a User on CentOS 6 VPS

To add a new user in CentOS, you will have to use the adduser command, replacing, in this exaple, “myusername” with your preferred username.

sudo adduser myusername

After you have created the new username you have to provide a new password for this user. Remember to confirm the password when asked by the system. You will not be able to see the password as being typed, this is a normal behavior for security reasons from the system. Create the new password with the following command:

sudo myusername passwd

You have just created a new user and its corresponding password to CentOS 6. You can log out of the root user by typing exit and then log back in with the new username and password.

How to Grant a User Root Privileges

Remember that for security reasons, your Virtual Server will be safer if you use your own username and grant root privileges instead of using the unrestricted default root user.

Create the sudo user by opening the sudoers file by typing:

sudo /usr/sbin/visudo

Find the line that says: "## Allow root to run any commands anywhere". Type “i” to start inserting text. Now you just need to add the recently created user following the root user line. This will grant root privileges to the added user.

## Allow root to run any commands anywhere
root   		ALL=(ALL)       ALL
myusername	ALL=(ALL)       ALL

Save and Exit the file by pressing "Escape" then type: "shift+:" then "wq+enter".

How to Delete a User from CentOS 6 VPS

If you no longer need to have a specific user on the virtual private server you can delete them with the following command:

sudo userdel myusername

You can add the option “-r” to the command if you would like to simultaneously remove the users’s home directory and files.

sudo userdel -r myusername

That's it! Now you have your VPS with your own username, protected with a unique password and granted root privileges to it.


Test on a Miami VPS Now


Deploy on a Miami Dedicated Server

Was this answer helpful? 26 Users Found This Useful (33 Votes)