How to add a new user with sudo rights

Sudo Sandwich
Image by xkcd – CC BY-NC 2.5

Let’s say you have a new user needing sudo access to a Linux server. How do you grant him/her this great privilege? First, explain to the new user that sudo rights allow to do pretty much anything on a Linux machine – including screwing everything up! – and that with greater power also comesĀ  greater responsibilities. Then, follow this procedure:

1. Open the command line

2. Create a new user (e.g. newusername) and add it to group wheel (members of this group have sudo rights):

sudo useradd -G wheel newusername

3. Set up the password for the new user. First, login as root:

sudo -i

Then set the password for the new user (e.g. newusername):

passwd newusername

Finally exit from root with:

exit

4. Test the newly created user and password by logging in as user newusername:

su - newusername

5. Test that the newly created user is in group wheel:

groups newusername

Leave a Reply

Your email address will not be published. Required fields are marked *