The adduser Command | Creating new users in Ubuntu Linux

As a system administrator working on an Ubuntu server, you must know how to add new users for the system. There are two commands.

The adduser which is an interactive command is the most straightforward method for creating a new user in Ubuntu, the other one is useradd command, it is a non interactive command.

Adding users with adduser

Creating a user is an easy task, thanks to the adduser command. In the following example, I am going to create a new user named administrator.

All you need to do is type adduser followed by the username, as shown in the following example:

adduser administrator

After you execute the adduser command, it will ask you to enter a password for the new user, then you need to retype the password.

ubuntu create user password

Then, it will prompt for some more information such as full name of the user. you don't have to answer those questions.

ubuntu create user

To skip these questions, simply press Enter without typing anything.

And that is it, the new user account is ready to use. However, this user does not have root privileges.

Granting sudo permissions

If the new user needs to perform administrative tasks such as installing software and managing other user accounts, you need to add the user to the sudo Linux group. We can do that using the usermod command.

usermod -aG sudo administrator

The user can now get root privileges using the sudo command.

Note that Ubuntu keeps user details in /etc/passwd file. Passwords are kept in /etc/shadow file.

Home directory

The adduser command creates the user's home folder under the /home directory. By default, this is /home/<username>, but you can change this by using the --home Flag.

adduser administrator --home /var/admin

This command creates a new user account, administrator, and creates a home folder at /var/admin for the user.

Do not set the password

The --disabled-login option, if used do not prompt for a password when you create a new user.

adduser administrator --disabled-login

User can't login to the system, until you set up a password with the passwd command.

passwd administrator
ubuntu passwd command