Ubuntu – Home directory not being created

bashcommand linehome-directoryusers

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

linda:x:1004:1004::/home/linda:/bin/sh

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?

Thanks.

Best Answer

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
       missing.

The directory will not be created if it is missing.

Generally keep away from useradd, use adduser instead.

Related Question