To change the default home directory of a user in Linux, you can use the usermod command. Here’s how to do it:
-
Open a terminal.
-
Run the following command, replacing
new_home_directorywith the desired path andusernamewith the name of the user:sudo usermod -d /path/to/new_home_directory usernameFor example, to change the home directory of a user named
jokerto/home/wayne, you would run:sudo usermod -d /home/wayne joker -
To verify the change, you can check the
/etc/passwdfile with:sudo grep -w 'username' /etc/passwd
This will show you the updated home directory for the specified user.
