Use useradd command create a new user or update default new user information from command line.
useradd testuser
passwd testuser
The above command will create a user named testuser and set its password to testuser.
Some important files that define various properties etc for this user:
- /etc/passwd - User account information.
- /etc/shadow - Secure user account information such as password.
- /etc/group - Group account information.
- /etc/default/useradd - Default values for account creation.
- /etc/skel/ - Directory containing default files.
- /etc/login.defs - Shadow password suite configuration.
Above command useradd will not create a home directory for this user. To create those try the below command that will create the user as well as home directory for it.
sudo useradd -m -k /etc/skel -d /home/testuser testuser
This will create a user named test user with a home directory /home/testuser and will have the same files and settings as in /etc/skel.
To delete the user follow command:
sudo userdel testuser
sudo useradd -m -k /etc/skel -d /home/testuser testuser
This will create a user named test user with a home directory /home/testuser and will have the same files and settings as in /etc/skel.
To delete the user follow command:
sudo userdel testuser