in Linux sudo user user management ~ read.

Add and Delete User on Ubuntu 14.04


When you first create a new server, there are a few configuration steps that you should take early on as part of the basic setup. One of the most basic tasks to that you should know how to do on a fresh Linux server is add and remove users.

When you create a new server, you are only given the root account by default. While this gives you a lot of power and flexibility, it is also dangerous and can be destructive. It is almost always a better idea to add an additional, unprivileged user to do common tasks. You also should create additional accounts for any other users you may have on your system. Each user should have a different account.

You should now have a fairly good handle on how to add and remove users from your Linux system. Effective user management will allow you to separate users and give them only the access that they are required to do their job.

You can still acquire administrator privileges when you need them through a mechanism called sudo. In this article I will show you how to create user accounts, assign sudo privileges, and delete users.

Add a User

If you are signed in as the root user, you can create a new user at any time by typing:

adduser newuser  

If you are signed in as a non-root user who has been given sudo privileges, you can add a new user by typing:

sudo adduser newuser  

Either way, you will be asked a few questions. The procedure will be:

  • Assign and confirm a password for the new user
  • Enter any additional information about the new user. This is entirely optional and can be skipped by hitting “ENTER” if you don’t wish to utilize these fields.
  • Finally, you’ll be asked to confirm that the information you provided was correct. Type “Y” to continue.

Your new user is now ready for use! Now, you can log in using the password which you set up.

Assign sudo privileges

Now, we have a new user account with regular account privileges. However, we may sometimes need to do administrative tasks. And you will need to give the new user access to sudo.

Option one :

To add these privileges to our new user, we need to add the new user to the “sudo” group. By default, on Ubuntu 14.04, users who belong to the “sudo” group are allowed to use the sudo command.

As root user, run this command to add your new user to the sudo group (substitute the highlighted word with your new user):

gpasswd -a newuser sudo  

If you are signed in as a non-root user who has been given sudo privileges, you can typing:

sudo gpasswd -a newuser sudo  

Now your user can run commands with super user privileges!

Option two :

We can do this by using the visudo command, which opens the appropriate configuration file in your editor. This is the safest way to make these changes.

If you are currently signed in as the root user, type:


If you are signed in using a non-root user with sudo privileges, type:

sudo visudo  

Search for the line that looks like this:

root    ALL=(ALL:ALL) ALL  

Below this line, copy the format you see here, changing only the word “root” to reference the new user that you would like to give sudo privileges to:

root ALL=(ALL:ALL) ALL newuser ALL=(ALL:ALL) ALL  

You should add a new line like this for each user that should be given full sudo privileges. When you are finished, you can save and close the file by hitting CTRL-X, followed by “Y”, and then hit “ENTER” to confirm.

Now, your new user is able to execute commands with administrative privileges.

Delete User

In the case that you no longer need a user, it is best to delete the old account.

You can delete the user itself, without deleting any files of user by typing this as root:

deluser newuser  

If you are signed in as another non-root user with sudo privileges, you could type:

sudo deluser newuser  

If, instead, you want to delete the user’s home directory when the user is deleted, you can issue the following command as root:

deluser --remove-home newuser  

If you are signed in as another non-root user with sudo privileges, you could type:

sudo deluser --remove-home newuser  

If you had configured sudo privileges for the user you deleted, you may want to remove the relevant line again by typing:


Or use this if you are a non-root user with sudo privileges:

sudo visudo  
root    ALL=(ALL:ALL) ALL  

Remove the line of user in this file and save, close file. So, you are finish to delete user.

comments powered by Disqus