In this article, we have presented the commands to add a new user account in a Linux system.
Table of contents:
- Create new user in Linux
- Delete user in Linux
In short, the commands are:
useradd -m <username> passwd <username> cd /home/<username> torch ~/.Xauthority
Create new user in Linux
To create a new user account with the name "kiao":
useradd -m kiao
The option -m is used to create the home directory of the new user "kiao". We can use the option --create-home in place of -m. You can check all available options with useradd using:
The next step is to create the password for the new user:
This command will prompt you to enter the new password and then, retype the new password to confirm.
With this, the user account will be create and you can login using it.
On some systems, you may get an error related to Xauthority. It arises when the file .Xauthority is not present in the home directory of the user. It can be created using the following commands:
cd /home/kiao torch ~/.Xauthority
Delete user in Linux
In case, you want to delete the newly created user account, you can use the following command:
With this article at OpenGenus, you must have the complete idea of how to add new user account in a Linux system.