Home>Article>Operation and Maintenance> How to modify the user directory in Linux

How to modify the user directory in Linux

WBOY
WBOY Original
2022-02-25 16:44:29 20308browse

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".

How to modify the user directory in Linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to modify the user directory in Linux

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

How to modify the user directory in Linux

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 Modify the remark text of the user account.

  • -dLogin directory> Modify the directory when the user logs in.

  • -e Modify the validity period of the account.

  • -f Modify the number of days after the password expires before the account will be closed.

  • -g Modify the groups to which the user belongs.

  • -G Modify the additional groups to which the user belongs.

  • -l Modify the user account name.

  • -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.

How to modify the user directory in Linux

Finally switch to the normal account and you will see that the current default directory has been changed.

How to modify the user directory in Linux

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!

Statement:
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