Add and Delete Users on Linux

Setup

This tutorial requires access to the root user or a user with sudo privileges. You should have received your root password from the welcome email after you launched your installation via customer console.

Users on Ubuntu

How to Add a User on Ubuntu 12.04

To add a new user in Ubuntu, use the adduser command, replacing the “newuser” with your preferred username.

sudo adduser newuser

As soon as you type this command, Ubuntu will automatically start the process:

  • Type in and confirm your password
  • Enter in the user’s information. This is not required, pressing enter will automatically fill in the field with the default information
  • Press Y (or enter) when Ubuntu asks you if the information is correct

Congratulations—you have just added a new user. 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:

sudo /usr/sbin/visudo

Adding the user’s name and the same permissions as root under the the user privilege specification will grant them the sudo privileges.

# User privilege specification
root    ALL=(ALL:ALL) ALL 
newuser	ALL=(ALL:ALL) ALL

Press ‘cntrl x’ to exit the file and then ‘Y’ to save it.

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

Finish up by the deleting the user’s home directory:

 sudo rm -rf /home/newuser
 

Users on CentOS 6

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 passwd newuser

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:

sudo /usr/sbin/visudo

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
 

Next Steps

Once you have set up the users will you need, you can start building up your VPS. A good place to start is to install the LAMP stack (a collection of basic web server software) on your droplet, using the tutorials in our knowlege.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

VMware vSphere Hypervisor

Hardware VMware vSphere Hypervisor 5.x and 6.0 (ESXi) use a filesystem called vmfs5 (formerly...

The rescue system and change de root password

Tu Cloud Server Rescue System The TCS Rescue System is a Linux live environment that allows you...

Instructions for install the new subnet or the new IP address

All dedicated and virtual servers come with an IPv4 address, as well as a /64 IPv6 subnet....

Main questions about VPS Servers

What kind of virtualization is used? The virtualization we use is based on KVM. We offer fully...

Reboot or Restart your dedicated server or VPS server

You can perform this action by yourself following these steps: 1- Login in your customer console...

Powered by WHMCompleteSolution