Change User Home Directory in UNIX & Linux

Method 1:

1. Execute below command.

# usermod -d /path/to/new/home-directory/ <username>

Method 2:

1. Open /etc/password with vi editor. Look for the user that you want to change the home directory. At the ” </path/to/old/home-directory/> “, change the location to the new location as needed.

# more /etc/passwd | grep <USERNAME>
<USERNAME>:x:1000:100:<USERNAME>:</path/to/old/home-directory/>:/bin/bash

change to

# more /etc/passwd | grep <USERNAME>
<USERNAME>:x:1000:100:<USERNAME>:</path/to/new/home-directory/>:/bin/bash

2. Save your work!

You May Also Like

Leave a Reply?