One of the first tasks when provisioning a new Ubuntu system is adding and removing users. Each user can have different permission levels and specific settings for various command-line and GUI applications.
This article explains how to add and remove user accounts on Ubuntu 18.04.
Only root or users with sudo privileges can create and remove users.
New users can be created in two ways:
In Ubuntu, there are two command-line tools that you can use to create a new user account: useradd
and adduser
.
[useradd](https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/)
is a low-level utility. adduser
is a script written in Perl that acts as a friendly interactive frontend for useradd
.
Adding a new user is quick and easy, simply invoke the adduser
command followed by the username. For example, to create a new user account named username
you would run:
sudo adduser username
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' ...
You will be asked a series of questions. Enter and confirm the new user password. Providing an answer to all other questions is optional.
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
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]
At the end, you’ll be prompted to confirm that the information you entered is correct.
The command will create the new user’s home directory, and copy files from /etc/skel
to it. Within the home directory, the user can write, edit, and delete files and directories.
If you want the new user to be able to perform administrative tasks, you need to add the user to the sudo group :
sudo usermod -aG sudo username
If you are not comfortable with the command line, you can add a new user account through the GUI. To do so, follow the steps below:
#ubuntu