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.

 

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 comment