Task Status - Failed - user 'yousuf' home directory is incorrect on App Server 2

systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
( yousuf:x:1018:1018::/var/www/yousuf:/bin/bash )

Can someone explain why this failed? I created the user yousuf when the home directory /var/www/yousuf and user ID of 1018 which the question asked but it failed.

first I installed httpd because httpd was not installed on appserver 2
then used this command to create the user ( useradd -u 1018 -b /var/www yousuf )
and it failed.

Any input is welcomed!!

hi, @kwamejustice03, as per question you need to use -d instead of -b in command with full home directory path

The –b option represents the location of base directory. The base directory is the directory where all users’ home directories are stored. The default base directory is the /home directory. If this option is used, supplied location will be used to create the user’s home directory. The name of user’s home directory will be same as username.

In the -b option, we only specify the path of base directory. While in the –d option, we specify both; the path of base directory and the name of the user’s home directory.

a little research I did with this question, both -b and -d does the same thing the only diff is with -d you specify the full path and with -b you provide the path and the users home directory is created with the user name which the question specified the user’s name and the home directory are the same.

I know there are more ways of solving a problem and think I should not fail that task.

Hi @kwamejustice03 While specifying the base directory using -b option you had to take care about the trailing / it should have been passed like this -b /var/www instead of -b /var/www/ because it will eventually append the home directory like this /var/www//yousuf (you could verify this from /etc/passwd).

Although you will still be able to switch to the user but there will be a wrong entry in the /etc/passwd file for this user which is incorrect as per task description.