Linux Change Default User Home Directory While Adding A New User

By default base directory for the system user is set to /home directory. I’d like to add user to /iscsi/home/${user} directory instead of the default /home. How do I force useradd command to add user to /iscsi/home under CentOS / RHEL / Fedora Linux server?

Default values for account creation defined in /etc/default/useradd file under CentOS / RHEL / Fedora / Debian / Ubuntu and other Linux distros. Simply open this file using a text editor, type:
# vi /etc/default/useradd
The default home directory defined by HOME variable, find line that read as follows:
Replace with:
Save and close the file. Now you can add user using regular useradd command:
# useradd vivek
# passwd vivek

Verify user information:
# finger vivek

Login: vivek                            Name: Vivek Gite
Directory: /iscsi/user/vivek                Shell: /bin/bash
Last login Thu Sep 13 07:58 2007 (IST) on pts/1 from
No mail.
No Plan.

How Do I Change Existing User’s Home Directory?

You need to use the usermod command to set the user’s new login directory. The syntax is as follows:

usermod -m -d /path/to/new/home/dir userNameHere


  1. -d dirnanme : Path to new login (home) directory.
  2. -m : The contents of the current home directory will be moved to the new home directory, which is created if it does not already exist.

In this example set the user’s new login directory to /users/v/vivek from /home/vivek, enter:
# usermod -m -d /users/v/vivek vivek

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 24 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
24 comments… add one
  • santhosh kumar theyyan May 6, 2008 @ 12:25

    or specify the home with -d in useradd command

  • ashwani May 23, 2009 @ 15:18

    Nice…info…but it doesnt work ;_( it still gives same error as before changeing in /etc/default/usradd

    [root@localhost ~]# useradd -d /root/lvm/ mas
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.

  • Jay A Jun 18, 2009 @ 10:24

    Hi All,
    Anyone who can teach me the solution for this problem:

    I add a user jayabellon using this command:
    useradd -u 888 -g oinstall -G dba -d /home/jayabellon -r jayabellon

    i forgot to create home directory when I log-In so it prompts me cannot go to that directory.

    I deleted the user and retry to create again.

    But still, when I log-In, this is what it looks like:

    I am expecting it to be

    this is my entry in /etc/passwd:

    actually, i am only working in a test server. Nothing much critical on this one.
    It’s just that its my first time to create user using command line, because i usually do it in GUI based.

    Jay A

    • divyaraj Feb 16, 2012 @ 7:23

      Even I have the same problem. If you get any solution please mail me. One solution I can give that re-install the operating system,even I did the same.

  • Jay A Jun 18, 2009 @ 10:27

    -bash-3.00$ finger jayabellon
    Login: jayabellon Name: jayabellon
    Directory: /home/jayabellon Shell: /bin/bash
    Never logged in.
    No mail.
    No Plan.

    • 🐧 nixCraft Jun 18, 2009 @ 11:10

      Pass -m option to useradd command to create users home dir.

  • Jay A Jun 19, 2009 @ 1:43

    I got it.

    it’s in man page also.


    found that it’s faster to create user in command line rather than using GUI Administration tool.

    Thanks Vivek

  • Shash Apr 27, 2010 @ 6:02

    Any chance you can provide a similar command for Oracle SQL?

  • TonyRiver Dec 29, 2011 @ 10:14

    Thanks. I’ve been wondering how to change the default home directory for a while now. Glad I found this to explain how.
    Your comment is awaiting moderation.

  • Tamjeed Apr 20, 2012 @ 8:16

    This is just nonsense of a blog, when the same thing can be achieved with usermod command with -d option to change the home directory.

    • Joey May 14, 2013 @ 13:54

      It’s really not “nonsense of a blog.” The whole point is so that it is a default, so you DON’T have to do the -d option every time. Why make things harder on yourself? Set all the defaults in the config files, and then just useradd and be done with it.

  • dnyaneshwar Oct 8, 2013 @ 6:01

    home directory already exits.
    not copying any file from skel directory into it
    when i login to oracle user it show me

  • sms Dec 10, 2013 @ 14:06

    Thanks a lot you saved me.. since the syntax was so complicated..

    what i did wrong was while trying to change existing username to new one..

    I was logged as root since it’s not good to change username while being logged under it.. everything went smooth i even appended the groups to my new user but since i didn’t specify the path to the new home directory after -dm all of the old folder was moved by default to the root folder instead of home since i was logged as root.. so be careful guys to specify path or just log into any other user you have that has folder in home$ or i guess excute the command in the target folder .. here what i used to change username:

    usermod -dm -Ga ,sudo -l

    to understand this go to the man page..

  • sms Dec 10, 2013 @ 14:08

    sorry but trying to add syntax with but gets deleted!!!

    add this to first comment

    usermod -dm (new-user) -Ga (created new group),sudo -l (new-user) (old-user)
  • sms Dec 10, 2013 @ 14:32

    forgot to mention that combining options letters won’t work which i guess is weird since it;s used in tar -vzf … but i guess some commands don’t agree.. thanks again i’ve just moved my whole folders to the destination.. u r the best not even the man instructions since those are stupid for not giving no examples.. thanks again guys..

  • XaverW Jan 30, 2014 @ 14:44

    Thanks for the article.
    When changing the default home dir in /etc/default/useradd, I suggest to change it in /etc/adduser.conf as well (variable DHOME) – otherwise users added by the command ‘adduser’ will have the wrong/old home still.

  • isiah May 13, 2014 @ 17:02

    on rhel 5 I had to change the command slightly

    usermod -d /users/v/vivek -m vivek

    this applies to centos 5 as well

  • mahendra bonamukkala Mar 8, 2015 @ 16:43

    it’s working both combination of -m -d options

    usermod -m -d

  • mahendra bonamukkala Mar 8, 2015 @ 16:44

    it’s working both combination of -m -d options
    usermod -m -d

  • Isaac Rosario Jun 16, 2015 @ 22:23

    I tried too many times but it’s telling me that my user is used by a process 3284

  • charu Jan 11, 2016 @ 10:20

    I created a user using adduser :
    useradd sacadmin
    and added it to a group alcatel.
    Now when I do su sacadmin it logs in, but there is no directory /sacadmin in /users.

    I need a directory in users for this user and a bin in it like /users/sscadmin/bin

  • nadeem Jun 25, 2016 @ 20:25

    can we Modify Oracle_Base directory to other new directory after installation. Plz help me

  • guruptr Mar 3, 2017 @ 8:02

    change home directory in user1
    #usermod -m -d /backup user1

    Error show in

    usermod: user user1 is currently logged in
    what is solve

    • 🐧 Vivek Gite Mar 3, 2017 @ 13:48

      Logout users1. Or kill user1 session:
      pkill -KILL -u user1

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum