Change User Home Directory From Command Line

 

By default when we add new user with useradd command (without specifying home directory) user home directory is set to /home/<userName>.

If we want to change user home directory from command line after adding new user, we need to edit /etc/passwd file with sudo/root permission.

Lets say we created a user.

$ useradd tempuser

By default tempuser home directory for /home/tempuser

If we want to change home directory to /home/temp, just open /etc/passwd file with any editor.

Search for the required user name for which you want to change the home directory. In above example for tempuser home directory looks like :/home/tempuser: and just change it to :/home/temp:, then save and exit from /etc/passwd file.

Now relogin and test for update you made, your home directory will be changed.

-Sany

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s