I'm trying to change the home directory to a different folder and my OS is not letting me do that. In Ubuntu I try to edit the useradd file but I can't figure out any way to save my changes that I made. Does anyone know how to do this?
You can use the usermod command to change the default home directory for a user. What this command does is edit the file /etc/passwd. Opening /etc/passwd you will find there is a line for every user, including system users (mysql, posftix, etc), with seven fields per line denoted by colons.
You can return to your home directory from anywhere in the directory structure by typing cd on its own. Remember to include the dollar sign in the command line: without it, the echo(C) command will simply return the word ``HOME''.
As root
usermod -d /path/to/new/directory username
Make sure your have created the new directory first with the mkdir command. Then login as yourself again, the directory is set during login.
sudo usermod -d /path/to/new/home -m username
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With