Read in 2 minutes
How To Create a Sudo User on Ubuntu
sudo is command designed to allow users to run programs with the security privileges of another user, by default the root user. In this guide we will show you how to create a new user with sudo privileges on Ubuntu.
Steps to create a sudo user
1) Log in to you Ubuntu server as the root user or a user with sudo privileges:
ssh [email protected]_ip_address
2) Create a new user account using the
username with the user name that you want to create.
You will be prompted to set and confirm the new user password. Make sure that the password for the new account is as strong as possible.
Adding user `username' ... Adding new group `username' (1001) ... Adding new user `username' (1001) with group `username' ... Creating home directory `/home/username' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully
Once you set the password the command will create a home directory for the user, copy several configuration files in the home directory and prompts you to set the new user’s information. If you want to leave all of this information blank just press
ENTER to accept the defaults.
Changing the user information for username Enter the new value, or press ENTER for the default Full Name : Room Number : Work Phone : Home Phone : Other : Is the information correct? [Y/n]
3) Add the new user to the
usermod -aG sudo username
By default on Ubuntu, members of the group
sudo are granted with sudo access.
How to use sudo
Switch to the newly created user:
su - username
To use sudo, simply prefix the command with
sudo and a space:
sudo ls -l /root
The first time you use sudo in a session, you will be prompted to enter the user password:
[sudo] password for username:
That’s all! Feel free to leave a comment if you have any questions.