Linux change user home directory from command line

 

By default if we add user from useradd command without any option it will be added in home directory.

To change home directory of a user we can use usermod command.

Lets try see an example to change user (test) home form /home to /home1.

Run following command to modify:

$ usermod -d /home1/test -m test

Now open /etc/passwd  file and search for test user where you can see home directory as /home1/test, previously it should be /home/test.

 

Advertisements

One comment on “Linux change user home directory from command line

  1. You might mention that this moves the existing directory over to the new one. Users may not want that to happen. If so, eliminate the -m option.

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