How to Modify a User's Home Directory on Linux

Reference:
Various ways to modify the home directory of Linux users

To modify the user's Home directory on Linux, follow the steps below:

  1. Make sure you are logged on to the system as a user with administrator privileges.

  2. Use usermodthe command to modify the user's home directory. The basic syntax of the command is as follows:

    sudo usermod -d /新的目录路径 用户名
    

    Replace /新的目录路径with the path of the new home directory you want to set, 用户名and the username of the target user.

    For example, to change the home directory of user "john" to /home/john/newhome, the following command can be executed:

    sudo usermod -d /home/john/newhome john
    
  3. After the modification is complete, you can use cdthe command to test whether the new Home directory takes effect. Make sure the new directory path exists and has proper permissions.

Note that modifying the Home directory may involve some system and application configuration, so proceed with caution and make sure to back up relevant user important data before making such changes.

Guess you like

Origin blog.csdn.net/linux_tcpdump/article/details/131648681