Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After I add a user using adduser, I can't see it via System->Administration->Users and Groups unless I logout and then login again. Is that normal?

Also, can I set a newly added user as a sudoer or do I have to change that only after adding it? How can I do that via the shell?

Finally, can I delete the original user that was created upon initial installation of Ubuntu, or is this user somehow 'special'?

share|improve this question
up vote 625 down vote accepted

Just add the user to the sudo group:

sudo adduser <username> sudo

The change will take effect the next time the user logs in.

This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

As long as you have access to a user that is in the same groups as your "original" user, you can delete the old one.

Realistically, there are also other groups your new user should be a member of. If you set the Account type of a user to Administrator in Users Settings, it will be placed in at least all of these groups:

adm sudo lpadmin sambashare

Because your system configuration may vary, I suggest taking a look at the output of groups <username> to see what groups are normally in use.

share|improve this answer
@Dziamid I'm not sure what the sudo group is for. Let's find out. – ændrük May 17 '11 at 1:49
Please note that the admin group doesn't exist in 12.04 LTS. – rxgx Jun 12 '12 at 1:10
The question is about an existing user, but if it was for a new user "sudo adduser <username> sudo" would have to be preceded by "sudo adduser <username>". Otherwise one get the error message "The user <username> does not exist". – Peter Mortensen Jun 1 '13 at 12:07
this didn't work for me. still can't use sudo. – chovy Oct 31 '13 at 7:37
Had to log in again for it to work. – PeterM Jun 9 '15 at 8:06

I did

sudo usermod -a -G sudo <username>

as recommended here.

share|improve this answer
doesn't work out of the box on centos 6 – jheriko Mar 8 at 16:02

Open the sudoers file: sudo visudo will open the /etc/sudoers file in GNU nano. If not, try export EDITOR="nano" and try sudo visudo again.

Add the below line to the end of file.

`username ALL=(ALL) ALL`   **Change the user name before you issue the commands**

Then perform WriteOut with Ctrl + O. The editor will ask you for the file name to write into. The default will be /etc/sudoers.tmp:

File Name to Write: /etc/sudoers.tmp

Change that to /etc/sudoers:

File Name to Write: /etc/sudoers

A prompt will be displayed:

File exists, OVERWRITE ?


Save file under DIFFERENT NAME ?

In both cases, press Y. Quit the nano editor with Ctrl + X.


share|improve this answer
It would be inadvisable to explicitly add a single user to the sudoers file instead of simply adding that user to the appropriate group sudo. – Kzqai May 5 '14 at 18:56
with sudo visudo you can output to /etc/sudoers.tmp, when leaving the editor it will overwrite /etc/sudoers by itself – Climbatize Apr 2 '15 at 19:44
and visudo will verify the syntax to make sure there are no errors – mchid Jun 29 '15 at 9:32
syntax error if using this . – jheriko Mar 8 at 16:04

One thing I have to add that I'm sure a lot of people don't understand:

Once you have already done a adduser "username", you can still come back and do a adduser "username" sudo, and it will then add that user to the group properly.

It actually won't work the first time around like sudo adduser username sudo. It will give you an error. Which in summary means you must first make the user account before you can add them to a group.

share|improve this answer

All members of the group admin, are in Ubuntu by default allowed to use sudo, so the easiest way is to add the user account to the admin group.

If you do not want to give the user account full root access, you need to edit the /etc/sudoer file with visudo (it makes sure that you do not have any syntax errors in the file and lose sudo capability altogether) in a way that you specify what commands this user (or a new group) can execute as root.

The sudoer manual will give you more information about this. You can specify which commands are permitted by a particular user/group to be executed as root.

share|improve this answer
I thought that was what the wheel group was for? – Marco Ceppi Oct 15 '10 at 13:05
@Marco I'm not familiar with that. Can you explain a little more? – ændrük Oct 15 '10 at 13:19
@MarcoCeppi, the wheel group was used on some systems to restrict what users could use su. Ubuntu uses sudo and the admin group. – psusi Nov 17 '11 at 15:03

on CentOS, I do as root

echo ' username ALL=(ALL)   ALL' >> /etc/sudoers
share|improve this answer

protected by Braiam Mar 9 '14 at 3:39

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.