Create User Account in UNIX / Linux

Published On: May 19th, 2015|Last Updated: January 7th, 2023|Categories: UNIX & Linux|Total Views: 1262|Daily Views: 1|

System administrator had access to create user accounts to allow users to login. They can create user account with default configuration or by custom configuration.

To Create User Account in UNIX / Linux

useradd command is used to add user account in Linux or Unix systems. Also there is an alternative command to add user is adduser command which is friendlier and very similar to ‘useradd’ command.

Syntax:

$ useradd USERNAME

Here USERNAME refers to the login name of the user. Please note that the USERNAME should be unique and not already exists.

Example:

$ useradd etechtricks

In the above example, a new user “spytm” account is created with default configurations. By using usermod command, user account values can be modified later.

To set password for the user

Once the user account is created, password should be assigned to the new user using passwd command otherwise the account remains locked.

Syntax:

$ passwd USERNAME

Once the above command is executed, you will get the prompt option to create password for the respected username.

Most commonly used options:

-d HOMEDIR By default user’s directory will be created under /home directory. -d option is used to change the home directory of the user.
-g GROUP To add the new user to the existing group.
-h This options shows help message and exit the operation.
-r To create a system account.

Leave A Comment