Javatpoint Logo
Javatpoint Logo

Linux Create User | Linux Add user | Linux user add command

The Linux server allows us to create more than one user after installation. Linux is a Multi-user system, which means more than one user can work in the same system at the same time. We are allowed to do so through the Setup agent.

We must have to create an account in order to work with Linux as we cannot keep working with the root account. We have one administrative account; a system administrator account is responsible for managing the user accounts and groups of the system.

Adding or removing a user is one of the most basic tasks of a new Linux server.

We are given only a root user account by a new Linux server. Adding a user account provides lots of power and accessibility to a particular user. It is a useful but insecure utility of the Linux server. It is good to add an unprivileged user to do common tasks. However, we can access the administrative privilege through sudo command-line utility.

Create User in Linux (Ubuntu)

There are two most common ways to add a user to a Linux server.

  • Graphically through user manager
  • By the useradd command (Terminal)

1. By Graphically through user manager

Linux GUI allows us to create a user from its functions. It is a straight forward process. To create a user to your Linux server, follow the below steps:

Step1: Goto system search and search for the setting and navigate to Detail-> About.

Step2: Click on the Users after that Unlock option given on the header. It will ask for the system security password to enter the password and click ok to continue. Consider the below image:

Linux Create User

Step3: Click on the Add User option to add a new user.

Linux Create User

Step4: Enter the user details like username and password and account type. We can create two types of accounts, which are Standard and Administrator. The standard account does not contain the sudo privilege. However, we can provide it later.

Linux Create User

Step5: Now, we have successfully created a new user called JTP2. Consider the below image.

Linux Create User

2. By the Linux useradd command

In Linux, useradd command is a command-line utility which is used to add or remove a user on a Linux server and Unix based operating system.

In a different type of Linux distribution, the useradd command may be slightly different.

The useradd command performs the below tasks:

  • It edits the files for newly created user like /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow.
  • It creates and opens a new home directory.
  • It allows us to set ownerships and permissions to the home directory.


In order to use the useradd command, we have to log-in with root or sudo access.

Before using Linux useradd command, let's understand some common terms that are used in the Linux command line.

  • Username: A username is a name that is used to login to the Linux system. It is displayed when we turn on our machine. The username length should be between 1 to 32 characters.

Password: A password is a secret code that is used to protect your system from unauthorized access. It is stored in etc/shadow file in an encrypted format.

User ID (UID): Linux provide a unique Id to every user; it is called user identification number or User ID or UID. By default, the UID for the root user is reserved as zero, and the remaining UID from 1 to 99 is reserved for other predefined accounts. Further, UID's from 100-999 are reserved for groups and system accounts.

Group ID (GID): The GID or Group ID is a group identification number provided by the Linux system. It is stored in /etc/group file.

User Info: It allows us to define some additional information about the user, such as user full name. It is optional.

Home Directory: It is an absolute location for a user.

Shell: It is an absolute location of a user's shell i.e. /bin/bash.

To create a new user by useradd command, execute the useradd command followed by username as follows:

The above command will ask for the system administration password, enter the password. It will create a user named as JTP3. This username is used by the user to login the system. The username must be unique. Consider the below output:

Linux Create User

To set the password for the newly created user, execute the below command:

The above command will ask for the new password, enter the password and retype the new password. It will update the password for the specified user. Consider the below output:

Linux Create User

Create a user with a home directory

Sometimes the newly created user may or may not assign a home directory. To create a user and to forcefully assign a home directory to it, execute the below command:

Consider the below snap of terminal:

Linux Create User

The above command will ask for the system administration password and create a directory home/Demo for the user Demo.

Create a user with a different home directory

Linux allows us to create a home directory on a different place instead of the default folder. Use the -d option with useradd command to create a different home directory. Execute the below command:

The above command will create a Demo1 folder under the root directory for the user Demo1. Consider the below snap of the terminal:

Linux Create User

Create a user with an expiry date

To create a user with an expiry date that means after a particular date, it will be auto-deleted.

The above command will create a user with a specified expiry date. It will create a user named Demo2, which will be auto-deleted after 16 March 2020. Consider the below snap of the terminal:

Linux Create User

It will be useful when you want to create an account for any user who is going to depart after a short period.

Next TopicLocal su Commands

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA