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 –
The last entry here, would show the user we just added –
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 –
It would return with the values we have provided –
We can also check for the group our user belongs to. This can be done through –
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.