How do you create a new user in Linux?

In Linux systems, you can use the following command to create a new user:

  1. create a new user
sudo useradd username

In this case, the username is the new user’s username.

  1. 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.

  1. 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
  1. Option: Assign new users to a specific user group.
sudo usermod -aG groupname username

“Where groupname is the name of the user group.”

  1. 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.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds