How to Create a User in Linux

How to create a user on Linux system


Creating or adding a new user is a basic and indispensable command in Linux. On the Internet, you can find that two commands are used to add a user, the first command is “adduser”, the second is “useradd”. Although both commands are added by the user, "useradd" has some advantages. The main advantage is that it is portable to the main Linux distributions, namely Red Hat Enterprise, CentOS, Debian, Ubuntu. While the "adduser" command can be used in Debian-based operating systems, namely Ubuntu and Mint. The "useradd" command is preferable as it is compatible with all Linux distributions. But in our article we will look at two methods.


Adding a new user using the "useradd" command:


useradd command

1. Opens a terminal in a Linux system

Please note that you need to use the actions as a root user.

2. Executes the following command

sudo useradd username


3. After creating a user, the new user is automatically in /etc/useradd file, the new user is locked. In order to unlock, run the following command

sudo passwd username


And re-enter the password.


Adding a new user using the "adduser" command:


adduser command

This command, like "useradd", is executed at the hands of the user. Next, let's look at an example of using the "adduser" command:

sudo adduser username


Wrapping up:


In our article, we tried to explain in as much detail as possible how to create a user in Linux. We hope these commands will be useful to you in your future work.