The sudo
command provides a mechanism for granting administrator privileges, ordinarily only available to the root user, to normal users. This guide will show you the easiest way to create a new user with sudo access on Ubuntu, without having to modify your server's sudoers
file. If you want to configure sudo for an existing user, simply skip to step 3.session
Log in to your server as the root
user.ssh
Use the adduser
command to add a new user to your system.ide
Be sure to replace username with the user that you want to create.ui
Set and confirm the new user's password at the prompt. A strong password is highly recommended!this
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Follow the prompts to set the new user's information. It is fine to accept the defaults to leave all of this information blank.spa
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]
Use the usermod
command to add the user to the sudo
group.code
By default, on Ubuntu, members of the sudo
group have sudo privileges.orm
Test sudo access on new user accountserver
Use the su
command to switch to the new user account.ip
As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges.
For example, you can list the contents of the /root
directory, which is normally only accessible to the root user.
The first time you use sudo
in a session, you will be prompted for the password of the user account. Enter the password to proceed.
[sudo] password for username:
If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.