Home > Article > Operation and Maintenance > Learn the important instructions for adding users in Linux
In Linux systems, adding users is a common operation. Mastering the key commands for adding users is of great significance for managing system users. This article will introduce the key commands for adding users in the Linux system and provide specific code examples to help readers master this operation step.
useradd
command is the key command to add a new user in the Linux system. Its syntax format is:
useradd [选项] 用户名
The following is A specific code example:
sudo useradd -m jerry
The above command will create a new user named jerry and create the home directory of user jerry in the /home directory.
After adding a user, you need to set a password for it. You can use the passwd
command to complete this step. The syntax format is:
passwd 用户名
The following is a specific code example:
sudo passwd jerry
After running this command, the system will prompt you to enter the new password of user jerry and confirm it.
usermod
command can be used to modify the attributes of a user account, such as changing the user's home directory, logging in to the Shell, etc. The syntax format is:
usermod [选项] 用户名
The following is a specific code example:
sudo usermod -s /bin/bash jerry
The above command sets the login shell of user jerry to bash.
If you need to delete a user, you can use the userdel
command. The syntax format is:
userdel [选项] 用户名
The following is a specific Code example:
sudo userdel -r jerry
The above command will delete the user named jerry and delete his home directory at the same time.
Through the above key commands and code examples, readers can master the steps of adding users in the Linux system, and also understand how to set passwords for users, modify user attributes, and delete users. These operations are a very basic and important part of Linux system management. I hope readers can become more proficient in user management operations through this article.
The above is the detailed content of Learn the important instructions for adding users in Linux. For more information, please follow other related articles on the PHP Chinese website!