Quickly master how to modify user information in Linux

WBOY
Release: 2024-02-25 09:45:13
Original
621 people have browsed it

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.

1. View current user information

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
Copy after login

This command will list all user information in the system, including user name, user ID, group ID, home directory, etc.

2. Modify user information

2.1 Modify user name

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
Copy after login

This command will change the user's username from old_username to new_username.

2.2 Modify the user’s home directory

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
Copy after login

This command The user's home directory will be modified to the specified path.

2.3 Modify user password

To modify the user's password, you can use the passwd command. The sample code is as follows:

sudo passwd username
Copy after login

The system will prompt you to enter the new password. password and confirmation password.

3. Add a new user

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
Copy after login

The system will prompt you Enter the new user's password and other information.

4. Delete users

If you need to delete a user, you can use the userdel command. The specific sample code is as follows:

sudo userdel username
Copy after login

This command will delete the specified User.

Summary

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!

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