LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2011, 12:32 PM   #1
crahuldba@gmail.com
Member
 
Registered: Apr 2010
Posts: 51

Rep: Reputation: 2
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

Last edited by crahuldba@gmail.com; 06-09-2011 at 01:18 PM.
 
Old 06-09-2011, 12:42 PM   #2
flamelord
Member
 
Registered: Jun 2011
Distribution: Arch Linux
Posts: 151

Rep: Reputation: 34
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
 
Old 06-09-2011, 01:21 PM   #3
crahuldba@gmail.com
Member
 
Registered: Apr 2010
Posts: 51

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by flamelord View Post
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
 
Old 06-10-2011, 02:20 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Try
Code:
usermod -m -d /home/newmukesh mukesh
 
Old 10-31-2015, 04:09 PM   #5
lightarrow
LQ Newbie
 
Registered: Oct 2015
Posts: 1

Rep: Reputation: Disabled
Smile Move users Home dir

sudo usermod -m -d /home/ubuntu/workspace/derpHome derp
 
Old 11-01-2015, 10:28 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How can i change my HOME (/home/user) directory location to something else? QueenZ Linux - Newbie 6 08-05-2010 07:26 AM
change samba home directory willy_gn Linux - Newbie 5 06-04-2010 04:46 PM
How change a userīs home directory? Roxxor2 Linux - Newbie 3 08-29-2009 07:32 AM
Change HOME directory? bhuwan Linux - Newbie 7 01-30-2006 10:19 AM
how to change a user's Home directory n1wil Linux - General 8 08-24-2002 04:22 PM


All times are GMT -5. The time now is 10:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration