Learn the important instructions for adding users in Linux

PHPz
Release: 2024-02-24 20:21:22
Original
1124 people have browsed it

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.

1. useradd command

useradd command is the key command to add a new user in the Linux system. Its syntax format is:

useradd [选项] 用户名
Copy after login

The following is A specific code example:

sudo useradd -m jerry
Copy after login

The above command will create a new user named jerry and create the home directory of user jerry in the /home directory.

2. passwd command

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 用户名
Copy after login

The following is a specific code example:

sudo passwd jerry
Copy after login

After running this command, the system will prompt you to enter the new password of user jerry and confirm it.

3. usermod command

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 [选项] 用户名
Copy after login

The following is a specific code example:

sudo usermod -s /bin/bash jerry
Copy after login

The above command sets the login shell of user jerry to bash.

4. userdel command

If you need to delete a user, you can use the userdel command. The syntax format is:

userdel [选项] 用户名
Copy after login

The following is a specific Code example:

sudo userdel -r jerry
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!