How to create a user account in linux?

One can login into the system if the user account has been created. Else, while login the user will get a error message saying “Access Denied”. In the following post, you will learn how to create a user account in linux.

Prerequisites:

1. Sudo access user account.

Things to mind before creating user a user account:

1. Verify the hostname of the system using below command.

hostname

2. Before creating one user account, ensure already the same user account name already exists for the same user using below command.

sudo cat /etc/passwd | grep –i <username |some other unique id>

or

grep –i <username |some other unique id> /etc/passwd

-i denotes case insensitive of letters.

Here are the steps to create a new user account in linux system.

Step 1 : If no user exist with id which is going to create, use the below command to create a user account.
sudo useradd <username>
Step 2 : Set a password for a created account using below command.
sudo passwd <username>

Step 3 : Verify the created account using below command.

sudo cat /etc/passwd | grep –i <username>
Step 4 : To change the user attributes or additional information about the user, run below command.
sudo usermod –c “Test user1” <username>

-c – Used to append additional information of the created user, this can be used while creating the user itself as below.

sudo useradd –c “Test user1” <username>

or

sudo useradd –c “Test user1” –d /tmp/user1 –s /bin/sh <username>

-d – Used to customize the user’s default home directory.
-s – Used to customize the user’s default login shell.

To know, how to provide a sudo access to created user account, Click Here!!

How do you feel about this post or want to suggest a new post? Drop your comments below..