sudo command is intended to permit users to run programs with the security privileges of another user, by default the
In this article, you will learn how to create a new user with
sudo access on Ubuntu OS. You would then be able to utilize this user to run admin commands without a need to signing in to your Ubuntu system as a
Steps to Create a Sudo User
Follow the steps below to create a new user and give it
sudo privileges. If you need to enable
sudo access to an existing user, jump to step 3.
1. Log in to your server.
Log in to your system as the root user:
2. Create a new user
adduser command to create a new user as shown below, and don't forget to replace
username with the user name that you want to create:
You will be prompted to set and confirm the new user password.
# Output: 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 make a home directory for the user, copy a few 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.
# Output: 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 sudo group
To add the user you created to the
sudo group use the
usermod -aG sudo username
Test the sudo access
Switch to the newly created user:
su - username
to run the
If the user have
sudo privileges then the output of the
command will be “
# Output: root