How do you create a new user in Linux?
In Linux systems, you can use the following command to create a new user:
- create a new user
sudo useradd username
In this case, the username is the new user’s username.
- Create a new password for the new user.
sudo passwd username
The system will prompt for the new user’s password and then require confirmation of the password.
- Optional: customize the personal information for new users, such as their real name, phone number, and more.
sudo usermod -c "Real Name" username
sudo usermod -s /bin/bash username
- Option: Assign new users to a specific user group.
sudo usermod -aG groupname username
“Where groupname is the name of the user group.”
- Option: Optional: Create a home directory for the new user (if not already created automatically):
sudo mkdir /home/username
sudo chown username:username /home/username
The username is the new user’s username.
Note: The “sudo” in the above command is used to execute the command with administrator privileges.