Title: Linux system user information modification steps and code examples
In the Linux system, user management is a very important task, including creating, modifying and deleting users wait. This article will introduce the specific steps on how to modify user information in a Linux system, and give corresponding code examples to help readers better understand and master related operations.
1. Steps to modify user information:
View user information: Enter the following command in the terminal to view all user information in the current system:
cat /etc/passwd
Modify user information: use the following command Modify the user's information, where 'user_name' is the user name of the user to be modified. You can modify the corresponding information content as needed.
Modify the user's password:
sudo passwd user_name
Modify the user's home directory:
sudo usermod -d /new_home_directory user_name
Modify User's Shell:
sudo usermod -s /bin/bash user_name
Modify the user's display name:
sudo usermod -c "New Name" user_name
Modify the user's group:
sudo usermod -g new_group user_name
2. Code example:
Suppose you want to modify the home directory of user 'john' to '/home/john_new', you can follow the following steps:
Execute the following command to modify the home directory of user 'john':
sudo usermod -d /home/john_new john
Confirm whether the modification is successful. You can use the following command to view the information of user 'john' :
cat /etc/passwd | grep john
Through the above steps and code examples, readers can learn how to modify user information in the Linux system, and at the same time strengthen their understanding and application of user management. I hope this article can help readers better use Linux systems for user management.
The above is the detailed content of How to change user information in Linux system. For more information, please follow other related articles on the PHP Chinese website!