How to create a user in Ubuntu

You can create a user on Ubuntu in just a few steps. Once you’ve created a user, you can add the new account to a sudo group if needed.

How to create an Ubuntu user and give them sudo rights

With the Linux sudo command users can initiate instructions at the root. They get temporary admin privileges, which an admin grants to an existing account or while creating a new user in Ubuntu.

Below we explain how to create a new user with add user in Ubuntu 20.04 and then how to add them to the sudo group.

Cloud Backup powered by Acronis
Mitigate downtime with total workload protection
  • Automatic backup & easy recovery
  • Intuitive scheduling and management
  • AI-based threat protection

Executing adduser in Ubuntu 20.04

If you want to create a new user in Ubuntu, first you’ll have to log into your server. To do so, use the following command, replacing the placeholder “your_server” with the IP address of your server:

$ ssh root@your_server
bash

Next, use the adduser command to create an Ubuntu account for a new user. In our example, the user is named “robin”.

# adduser robin
bash

The system will now prompt you to choose a secure password for the new user. Type the password in after the colon and repeat it in the next line:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
bash

Then you’ll be asked to enter some information about the new user. You can also skip this step. When you’re finished, confirm with [Y].

Changing the user information for robin
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]
bash

If you want to create additional Ubuntu users, repeat those steps.

Assigning sudo privileges to the account

If you want to give sudo privileges to a new or existing account, you’ll need to add it to the sudo group. You should only do this for users you know and trust. By default, all accounts in the group get full sudo privileges. For our user “robin”, the command will look as follows:

# usermod -aG sudo robin
bash

Don’t forget to substitute “robin” for the name of your user.

Checking sudo privileges

After you’ve created the new Ubuntu user and added them to the sudo group, you can make sure the process was successful with the following command:

# su - robin
bash

That command changes to the profile of the new user. Now execute a command that requires sudo privileges. The following command grants access to the root directory, which is only accessible for sudo users:

$ sudo ls -la /root
bash

Then you’ll be asked to enter the password for this account. If the account is part of the sudo group, you’ll now have access to the /root directory.

Note

Make sure that you only use root access when it’s absolutely necessary and take into account system security. Ideally, you should work with a non-root account that has sudo privileges.

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top