Home > Article > Operation and Maintenance > Quickly master how to modify user information in Linux
Learning to modify user information in Linux is a very important skill, especially for system administrators. In Linux systems, the management of users and user groups is one of the most common operations. This article will introduce how to quickly learn to modify user information in Linux and provide specific code examples.
Before starting to modify user information, we first need to know the user information that already exists in the current system. You can view it through the following command:
cat /etc/passwd
This command will list all user information in the system, including user name, user ID, group ID, home directory, etc.
To modify the user's user name, you can use the usermod
command. The specific sample code is as follows:
sudo usermod -l new_username old_username
This command will change the user's username from old_username to new_username.
If you need to modify the user’s home directory, you can use the usermod
command. The sample code is as follows:
sudo usermod -d /new/home/directory username
This command The user's home directory will be modified to the specified path.
To modify the user's password, you can use the passwd
command. The sample code is as follows:
sudo passwd username
The system will prompt you to enter the new password. password and confirmation password.
If you need to add a new user, you can use the adduser
command. The specific sample code is as follows:
sudo adduser new_username
The system will prompt you Enter the new user's password and other information.
If you need to delete a user, you can use the userdel
command. The specific sample code is as follows:
sudo userdel username
This command will delete the specified User.
Through the introduction of this article, we have learned how to quickly modify user information in Linux and provided specific code examples. For system administrators, it is very important to be proficient in these operations. I hope this article can help you better manage user information in Linux systems.
The above is the detailed content of Quickly master how to modify user information in Linux. For more information, please follow other related articles on the PHP Chinese website!