How do you change the home directory of a user in Linux? 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.
How do I create a home directory for an existing user? To create a default home directory use mkhomedir_helper command. Make sure to run mkhomedir_helper command as root or user with sudo access. The previous command creates a home directory named “/home/bob” and user settings files.
How do I change the home directory in Linux terminal?
- To return to the home directory immediately, use cd ~ OR cd.
- To change into the root directory of Linux file system, use cd / .
- To go into the root user directory, run cd /root/ as root user.
- To navigate up one directory level up, use cd ..
How do I create a user’s home directory in Ubuntu? Change default directory during user creation
However, if you want to set the default home folder of new user when you create it, then you need to use useradd command. Here is an example to change user ubuntu’s default folder to /home/data instead of /home/ubuntu. That’s it.