Command to change the default home directory of a user

后端 未结 6 1118
轻奢々
轻奢々 2020-12-07 08:00

I would like to know whether there is any simple shell command to change the user home directory in Linux/Unix (one similar to chsh which changes the defaul

6条回答
  •  日久生厌
    2020-12-07 08:34

    The accepted answer is faulty, since the contents from the initial user folder are not moved using it. I am going to add another answer to correct it:

    sudo usermod -d /newhome/username -m username
    

    You don't need to create the folder with username and this will also move your files from the initial user folder to /newhome/username folder.

提交回复
热议问题