LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   CHANGE HOME DIRECTORY USING usermod -dm (https://www.linuxquestions.org/questions/linux-newbie-8/change-home-directory-using-usermod-dm-885447/)

crahuldba@gmail.com 06-09-2011 11:32 AM

CHANGE HOME DIRECTORY USING usermod -dm
 
Hello Friends
I am facing a problem in changing the home directory of a user.
I have a user mukesh with home directory /home/mukesh
and i want to change the home directory to /home/newmukesh
as well as i want to move the all content of /home/mukesh to /home/newmukesh
is this right command for this purpose
usermod -md /home/newmukesh mukesh
This is the output of above command
[root@server1 ~]# usermod -md /home/newmukesh mukesh
Usage: usermod [options] LOGIN

Options:
-a, --append append the user to the supplemental GROUPS
(use only with -G)
-c, --comment COMMENT new value of the GECOS field
-d, --home HOME_DIR new home directory for the user account
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, --gid GROUP force use GROUP as new primary group
-G, --groups GROUPS new list of supplementary GROUPS
-h, --help display this help message and exit
-l, --login NEW_LOGIN new value of the login name
-L, --lock lock the user account
-m, --move-home move contents of the home directory to the new
location (use only with -d)
-o, --non-unique allow using duplicate (non-unique) UID
-p, --password PASSWORD use encrypted password for the new password
-s, --shell SHELL new login shell for the user account
-u, --uid UID new UID for the user account
-U, --unlock unlock the user account
-Z, --selinux-user new selinux user mapping for the user account

Please tell me the exact command for this.

Thanks
Rahul Sharma


Thanks Sir for your quick response but i have checked there is no /home/newmukesh exist and i have type exactly as you say
usermod -md /home/newmukesh mukesh

flamelord 06-09-2011 11:42 AM

That command works for me.
Make sure that /home/newmukesh doesn't already exist and make sure that you have -md not -dm, the order matters. Maybe you could try removing the space between the d and the HOME_DIR

crahuldba@gmail.com 06-09-2011 12:21 PM

Quote:

Originally Posted by flamelord (Post 4381138)
That command works for me.
Make sure that /home/newmukesh doesn't already exist and make sure that you have -md not -dm, the order matters. Maybe you could try removing the space between the d and the HOME_DIR

Sir i still have same problem
I dont have any /home/newmukesh directory
and i type
usermod -md /home/newmukesh mukesh

Thanks
Rahul Sharma

chrism01 06-10-2011 01:20 AM

Try
Code:

usermod -m -d /home/newmukesh mukesh

lightarrow 10-31-2015 03:09 PM

Move users Home dir
 
sudo usermod -m -d /home/ubuntu/workspace/derpHome derp

chrism01 11-01-2015 09:28 PM

@lightarrow: this thread finished in 2011.
Also, the OP was already logged in as root; see post #1


All times are GMT -5. The time now is 03:04 AM.