Nov 8, 2018

How to Change Default User Home Directory for New and Existing User in Linux

Default values for account creation defined in /etc/default/useradd file under CentOS / RHEL / Fedora / Debian / Ubuntu and other Linux distros. Simply open this file using a text editor, type:
# vi /etc/default/useradd

The default home directory defined by HOME variable, find line that read as follows:

Replace with:

Save and close the file. Now you can add user using regular useradd command:
# useradd i88ca
# passwd i88ca

Verify user information:
# finger i88ca


Login: i88ca                            Name: I88 CA
Directory: /home2/i88ca                Shell: /bin/bash
Last login Thu Sep 18 08:58 2014 (IST) on pts/1 from
No mail.
No Plan.

To Change Existing User's Home Directory:

You need to use the usermod command to set the user's new login directory. The syntax is as follows:

usermod -m -d /path/to/new/home/dir userNameHere


-d dirnanme : Path to new login (home) directory.
-m : The contents of the current home directory will be moved to the new home directory, which is created if it does not already exist.

The following change the user's new login directory to /home2/i88ca from /home/i88ca:
# usermod -m -d /home2/i88ca i88ca