In Linux system, each user has his own user account information, including user name, user ID, group ID, home directory, etc. If you need to modify user information, you can do so through the command line tool. The following will introduce the specific steps and sample code on how to modify user information under the Linux system.
First we need to confirm the user information to be modified. You can use the following command to view the detailed information of the current user:
$ id
You can use the usermod
command to modify the user ID and group ID. The command format is as follows:
$ sudo usermod -u <新的用户ID> -g <新的组ID> <用户名>
For example, the command to modify the ID of user testuser
to 1001 and the group ID to 1001 is as follows:
$ sudo usermod -u 1001 -g 1001 testuser
If you need to modify the user name, You can use the usermod
command with the -l
parameter to modify it. The command format is as follows:
$ sudo usermod -l <新的用户名> <旧用户名>
For example, modify the user name of user olduser
# The command of ##newuser is as follows:
$ sudo usermod -l newuser olduser
usermod command with
-d parameters are modified, the command format is as follows:
$ sudo usermod -d <新的家目录> <用户名>
testuser to
/home/newdir is as follows:
$ sudo usermod -d /home/newdir testuser
usermod command with the
-s parameter to modify it. The command The format is as follows:
$ sudo usermod -s <新的Shell路径> <用户名>
testuser to
/bin/bash is as follows:
$ sudo usermod -s /bin/bash testuser
$ id <用户名>
The above is the detailed content of How to update user information in Linux system. For more information, please follow other related articles on the PHP Chinese website!