In today’s article I will tell you about Create User in Linux.
While working on Linux, we need different users for logging or for different operations.
For this, we may need to perform operations such as creating a user,
changing the user’s password, but to do this, it must be done with the root user.
Creating a User
We use useradd and adduser commands to create users.
We can use the following command to add users with Adduser.
1 | adduser farukerdem |
We can use the following command to add users with useradd.
1 | useradd farukerdem |
While using the above commands,
we can set a password with the -p parameter, or we can create the home directory with the -G parameter, which group it will be included in, and the -m parameter.
More than one parameter like this can be used.
We can see the relevant parameters of useradd or adduser commands by typing –help.
Setting User Password
You have created a user, but if you want to set the password or change the current user’s password,
you can use the command below.
1 | passwd |
When you run the password command with the user you are connected to, it will change the password of the user you are connected to.
To change the password of a different user,
the password can be changed by typing the relevant user at the end of the password command as follows.
Example usage is as follows.
1 | passwd farukerdem |
You can use the command below to list users.
1 | cut -d: -f1 /etc/passwd |