I am trying to understand system administration on Ubuntu. So, as an example, I create a dummy user using

sudo useradd -d /home/linda linda

and passwd to create the password. I check that an entry has been made using cat /etc/passwd


However, when I su - linda, I get

No directory, logging in with HOME=/

and indeed, no home directory has been created. What am I missing?


10 Answers 10


man useradd states:

useradd is a low level utility for adding users. On Debian,
administrators should usually use adduser(8) instead.

Note the low level utility

To add a user, use adduser instead. It's a more high-level utility.

Moreover, looking at the -d option:

   -d, --home HOME_DIR
       The new user will be created using HOME_DIR as the value for the
       user's login directory. The default is to append the LOGIN name to
       BASE_DIR and use that as the login directory name. The directory
       HOME_DIR does not have to exist but will not be created if it is

The directory will not be created if it is missing.

Generally keep away from useradd, use adduser instead.

| improve this answer | |
  • 2
    In the OP's defense, when I read "On Debian,", I thought it meant on Debian as opposed to Ubuntu distros. I am aware that Ubuntu is built on Debian but thought that a distinction was being made. – Keith Bennett May 15 '15 at 16:11
  • 1
    I used adduser but still the created home directory only contains a file examples.desktop and nothing else. How can I get Ubuntu to create the default folders Desktop, Downloads and so on? (I'm logged in via ssh) – mcExchange Aug 13 '15 at 11:35
  • Hi, sorry late response and only guessing but I think those folders are created automatically on the first GUI login. Just thought people might still land here ;) – derHugo Nov 6 '17 at 7:59
  • adduser will not create the directory either if someone has changed CREATE_HOME in /etc/login.defs to "no". You can override this with the -m flag. – Noumenon Jun 11 '18 at 22:35

you can fix this simply by creating the home dir.

mkdir /home/linda
chown linda:linda /home/linda

try logging in again and this should work.

| improve this answer | |

According with man useradd, -d /home/linda option will not create the directory /home/linda, if this is missing. So, you have to create it manually. To do this, run the followings commands in terminal:

sudo -i                            #to get root privileges
mkdir /home/linda                  #to create the directory /home/linda
cp -rT /etc/skel /home/linda         #to populate /home/linda with default files and folders
chown -R linda:linda /home/linda   #to change the owner of /home/linda to user linda

See also: How to make user home folder after account creation?

| improve this answer | |
  • This is the correct answer. – Mike Q Jan 15 at 4:41

Look at /etc/defaults/useradd if you want to change the defaults. Use:

useradd -m -d /home/joe -s /bin/bash.

| improve this answer | |
  • 1
    "According with man useradd, -d /home/linda option will not create the directory /home/linda" so no, this is not a solution. – astrojuanlu Nov 2 '17 at 13:59
  • 1
    According to the useradd man page, that's what the -m flag is for:-m, --create-home Create the user's home directory if it does not exist. The files and directories contained in the skeleton directory (which can be defined with the -k option) will be copied to the home directory. useradd will create the home directory unless CREATE_HOME in /etc/login.defs is set to no.@astrojuanlu – Myles May 29 '19 at 12:44

You can also modify /etc/pam.d/common-session to make it so that a user's home directory will be created on first log in. Add the following line to that file.

session required pam_mkhomedir.so

This is particularly useful if your system is on a network where the users are managed externally to your machine, by LDAP for instance.

| improve this answer | |

Use -m instead of -d, so the directory will be created for you:

sudo useradd -m linda

Also, if linda is a normal user, you might want her to use /bin/bash as default shell:

sudo useradd -m linda -s /bin/bash

| improve this answer | |

Add the below entry in /etc/login.defs and save:


Now, try to create user accounts. It will create the home directory.

| improve this answer | |
  • It worked for me. I needed to have a basic script that will remotely add/manage users on different flavors of Linux. After this change my code produces same results on all servers. Thanks. – sdkks Feb 18 '16 at 2:36

Use adduser.


 adduser  and  addgroup  add users and groups to the system according to
   command    line    options    and    configuration    information    in
   /etc/adduser.conf.   They  are  friendlier  front ends to the low level
   tools like useradd, groupadd and usermod programs, by default  choosing
   Debian  policy conformant UID and GID values, creating a home directory
   with skeletal configuration, running a custom script,  and  other  fea‐
   tures.  adduser and addgroup can be run in one of five modes:

useradd you have to add all options yourself. Including permissions and some other things.adduser does this based on sane defaults (and also adds home dir by itself).

If you need to use adduser you probably need the -b option together with the -d option!

| improve this answer | |

If /home/linda is not present before you add linda as a user, you also would have to add --create-home.

sudo useradd --create-home linda
| improve this answer | |

The most likely reason why you did not have the home directory created is because you did not have the CREATE_HOME yes in /etc/login.defs.

You can fix this by following what @OmPS or @Radu Rădeanu had suggested.

But that many ways to overcome this problem in future by using one of the commands below:

  • Result of sudo adduser linda

    Adding user 'linda'
    Adding new group 'linda' (1001) ...
    Adding new user 'linda' (1001) with group 'linda' ...
    Creating home directory '/home/linda' ...
    Copying files from '/etc/skel' ...
    ****Password confirmation****
    ****Name prompt****

    The defaults for adduser are chosen from /etc/adduser.conf if --home option is not specified. Note that it also copies the /etc/skel contents.

  • Use adduser with --home

    sudo adduser --home /home/linda

Same as previous option except that you may want this if the users home directory is different than the username that you assigned.

  • Specify base directory to useradd command:

    sudo useradd -b /home
  • Use login.defs: Modify /etc/login.defs and add the line below before doing sudo useradd:

    CREATE_HOME   yes

Note: if you do man login.defs, it currently says

Much of the functionality that used to be provided by the shadow password suite is now handled by PAM. Thus, /etc/login.defs is no longer used by passwd(1), or less used by login(1), and su(1). Please refer to the corresponding PAM configuration files instead.

  • Use pam_mkhomedir PAM module: from man pam_mkhomedir page, add the line below to /etc/pam.d/login:

    session  required  pam_mkhomedir.so skel=/etc/skel
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.