PC Repaire Windows Error

How to Create a User in Linux

by | May 16, 2020

how to add user in linux

Adduser and addgroup: interactive tools for creating a user account and a user group

What is a user account?

adduser is a tool in console mode allowing to create a user account in an interactive way. It is a Perl script specific to Debian and its derived distributions – such as Ubuntu – that asks questions about an account to create, then invokes the usermod program and passes the information it retrieves as arguments. This tool is therefore very easy and intuitive to use. addgroup is its counterpart in terms of creating a user group.

Only a system administrator can create a new user account or group.

Ubuntu, like all other operating systems in the GNU/Linux family, is inherently multi-user. This means that you are not limited to a single user account in the operation of your computer. You can create multiple user accounts for each user of your computer, as well as for various uses.

1. adduser

The adduser command, invoked by an administration account, starts the user account creation script :

sudo adduser username

The information to be assigned to the new user account is then requested one by one. Pressing the [Enter] key on the keypad registers the information entered and proceeds to the next question.

When all the required information has been retrieved, a summary is presented to the administrator. The administrator must then confirm the creation of the new account or repeat the operation. Upon confirmation of the information, the script calls useradd to create the new account and creates a new personal folder from the structure contained in the /etc/skel/ directory.

Some options can be specified to adduser, to provide some additional parameters. See the adduser manual to read more about these options.

       1.1 Example

[email protected]:~$ sudo adduser jdoe

[sudo] password for administrator:  

Adding user `jdoe' ...
Adding new group `jdoe' (1001) ...
Adding new user `jdoe' (1001) with group `jdoe' ...
Creating home directory `/home/jdoe' ...
Copying files from `/etc/skel' ...

Enter the new UNIX password: (new password)

Retype the new UNIX password: (password repeated)

Changing the user information for jdoe

Enter the new value, or press ENTER for the default

	Full Name []: John Doe
	Room Number []: 333, Av. Blalak
	Work Phone []: (555) 123-4567
	Home Phone []: (555) 987-6543
	Other []: [email protected]
Is the information correct? [Y/n] y
[email protected]:~$ _

To force the user to change the password the first time he logs in, you can use the passwd command.

[email protected]:~$ sudo passwd -e jdoe
passwd: password expiration modified.


2. addgroup

The addgroup command, invoked by an administrative account, starts the user group creation script :

sudo addgroup groupName

To assign a user account to this new group, use adduser as follows:

sudo adduser userName groupName

where identifier is an existing user account identifier. The account must already exist; the command does not work with an account that does not exist.

          2.2 Example

[email protected]:~$ sudo addgroup familly
[sudo] password for administrator:        
Adding group 'familly' (GID 1002) ...

[email protected]:~$ sudo adduser jdoefamilly
Adding user 'jdoe' to group 'familly' ...
Adding user jdoe to group familly

3. Create an account or a user group in a non-interactive way

Adduser and addgroup are interactive tools, i.e. they ask a series of questions that must be answered by the administrator in order for the account or user group to be created. This is interesting to create a single account or group, but becomes a handicap to create several at the same time. adduser and addgroup are not scriptable. To use a non-interactive tool, ask about :

 useradd for user accounts
groupadd for user groups

4. Impacted files

The above commands modify the following system files, which are obviously not recommended to modify manually:


The /etc/passwd file contains the following information about user accounts :


username is the user’s login.
password corresponds to the user’s password replaced by an x for security reasons.
uuid is the user’s system ID.
guid is the user’s main group.
comment (sometimes called GECOS field) is a textual comment about the user, which is often his real name (first and last name) and other information (office number, phone…) separated by commas.
home corresponds to the home directory of the user on this system, /dev/null if account without home (on a server).
shell is the user’s default shell interpreter, /bin/false to prevent shell use (on a server).

Related Articles

How to Unbrick Your A95X MAX TV Box

How to Unbrick Your A95X MAX TV Box

The Story : After Installing a SuperSu in my A95X MAX Tv Box, the box didn't want to reboot, then i did manage to flash a custom rom using the SD card method, but then i didn't know that this will break my Box, doing so my box was dead no boot logo no usb connection...

Thou shalt always(ish) use UTF-8 in PHP

Thou shalt always(ish) use UTF-8 in PHP

Character sets are a mystery to many native-English coders, and if you're not aware of them then you'll occasionally find that things break, or go weird. Unicode was designed to replace all existing character sets with a single universal one. This article explains how...

Using prepared statements in PHP

Using prepared statements in PHP

Whether you're reading from, or writing to a database, using prepared statements are easy, convenient, and secure. So what are they? About these examples The examples here are all for PHP's built-in database layer, PDO, but many other database layers also support...