Add users in Ubuntu

We utilize the command-line utility adduser, to add users in Ubuntu. The utility is pretty ease to use. Its just that we need superuser privileges. If you don’t have the superuser privileges then, contact your System Administrator for assistance.

Everyone who has the access to the system should have an user id. And, for that we need to create a user. That way, we can effectively manage system resources. Furthermore, a System Administrator can limit a users’ access to critical resources.

Add users in Ubuntu

To add a user, use the following syntax –

sudo adduser <user_name>

So, if we want to add a user – xyz. Then it would be –

sudo adduser xyz

It would ask for the password. Enter the password. It asks for the password twice. Thereafter, enter personal details like Full Name, Contact numbers etc. Lastly, Press Y/n to verify. If all details are entered correct then, Press Y. It creates a user with <user_name>.

Use cat command-line utility to check whether user is available now –

cat /etc/passwd

The last entry here, would show the user we just added –

xyz:x:1002:1002:,,,:/home/xyz:/bin/bash

This was all about default values. But, what if we want a customized solution. This can be done by providing options and few of those are –

–home DIR, we can choose a user’s Home directory as per our preference.

–shell SHELL, the default login shell for the user.

–ingroup GROUP, can place the user in an existing group. We have used this option in an example below.

–disabled-login, the user can’t login unless the password is set. Lastly,

–no-create-home, home directory isn’t created.

We will utilize three options from above, and this see the observe the changes.

sudo adduser abc --home /home/test --shell /bin/sh --ingroup test

Again, use –

cat /etc/passwd

It would return with the values we have provided –

abc:x:1003:1000:,,,:/home/test:/bin/sh

We can also check for the group our user belongs to. This can be done through –

groups <username>

So, check for both xyz and abc users –

groups xyz
group abc

In conclusion, we have covered how to add users in Ubuntu here. In next article, we cover how to delete a user in Ubuntu.

Similar Posts