Home>Article>Operation and Maintenance> How to modify the user directory in Linux
How to modify the Linux user directory: 1. Use the "vi /etc/passwd" command to modify the "/etc/passwd" file to modify the user directory; 2. Use the usermod command to modify it, the syntax is "usermod - d username -u uid".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The first method:
vi /etc/passwd
Find the lines of the user you want to modify and modify them. This method is very violent and is recommended to be used with caution.
/etc/passwd file format
Login name: Encrypted password: Numeric user ID: Numeric group ID: Comment field: Starting directory: shell program
Use this method After modifying the user's host directory, certain exceptions will occur, such as: bash environment exception, you need to copy the hidden files in the user's original host directory to the changed host directory
cp /original host directory/ .*/Target directory
Second type: usermod
usermod -d /usr/newfolder -u uid
-u must be followed by uid, not username
Attachment: usermod detailed parameters
Syntax:
usermod [-LU][-c <备注>][-d <登入目录>][-e <有效期限>][- f <缓冲天数>][-g <群组>][-G <群组>][-l <帐号名称>][-s ][-u ] [用户帐号]
Supplementary instructions: usermod can be used to modify various settings of the user account.
Parameters:
-c
-dLogin directory> Modify the directory when the user logs in.
-e
-f
-g
-G
-l
-L Lock the user password and make the password invalid.
-s Modify the shell used by the user after logging in.
-u Modify user ID.
-U Unlock the password.
Finally switch to the normal account and you will see that the current default directory has been changed.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to modify the user directory in Linux. For more information, please follow other related articles on the PHP Chinese website!