1

I created a user without home directory using useradd -M Alice and set a password. Now when I login, I get this message

No directory /home/Alice! Logging in with home= "/"
-bash-4.1$

Can anyone explain the meaning of last line and solve this issue?

1
  • Well since there is no /home directory set for Alice, you may want to go into /etc/passwd and add a directory for that user..
    – ryekayo
    Commented May 27, 2016 at 15:53

3 Answers 3

1

I think you can solve it like that:

mkdir /home/Alice

chown -R Alice:Alice /home/Alice

Even better if you use adduser instead of useradd, the directory will create automatically.

1

The -M flag for useradd means "do not create the user's home directory", so the program has done what you asked.

You can fix the problem by creating a home directory for Alice and copying in the template files:

home=$(getent passwd Alice | cut -d: -f6)
uid=$(getent passwd Alice | cut -d: -f3)
gid=$(getent passwd Alice | cut -d: -f4)
mkdir -m755 "$home"
cp -a /etc/skel/. "$home"
chown -R $uid:$gid "$home"
0

Logging in with home= "/" means what it says. Since there is no home directory for the user, the login has used the root directory "/"

The -bash-4.1$ is the default bash prompt. You see that when there is no ~/.bashrc nor other default bash files. These are normally created, stored and updated in the user's home directory.

Using "/" as the home directory will cause other problems, as the user Alice most likely does not have permissions to write to the root directory of the filesystem. :-)

As roaima and Luciano Andress Martini wrote, you can fix this issue by creating a home directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .