Task: Linux user without home

As per the task, I am supposed to create a user by name james under app1.

This blog has examples of accomplishing this task.

Accordingly, I have executed the commands.
image

Man page for useradd:

image

image

While I am verifying my results. I see james is created under /home directory.


am I reading this output correctly?

Hi,

This seems correct. To verify also check if there is any directory created under /home for this user.

Thanks
Inderpreet

Thank you Inderpreet. Looks like I am good to go.

1 Like

Hi Inderpreet,

I did use the same command

useradd -M kareem

but still when submitted the Task it comes failed.

Could you please guide on what was done wrong here ? Thanks.

Regards,
Munjal

Hi Munjal,

Technically your answer is correct. The reason task failed for you is, you created a file /home/kareem manually hence that was considered as home of user kareem because in passwd home directory of user is /home/kareem. We updated checks a little to handle such scenarios and marking your answer as SUCCESS.

Hi Inderpreet,

Thanks for your reply. Yes After I ran the command to create a user “useradd -M kareem” , I tried to copy a file to that directory to confirm that the directory does not exist.

In spite of using the command “useradd -M kareem” or with other username, the /etc/passwd still shows a /home dir for all users that were created,

[steve@stapp02 ~]$ sudo useradd -M munjal
[steve@stapp02 ~]$ sudo useradd amit
[steve@stapp02 ~]$
[steve@stapp02 ~]$
[steve@stapp02 ~]$ sudo cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
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
ansible:x:1000:1000::/home/ansible:/bin/bash
steve:x:1001:1001::/home/steve:/bin/bash
kareem:x:1002:1002::/home/kareem:/bin/bash
munjal:x:1003:1003::/home/munjal:/bin/bash <<-------
amit:x:1004:1004::/home/amit:/bin/bash <<----------
[steve@stapp02 ~]$
[steve@stapp02 ~]$

user munjal and amit both showed the home dir in /etc/passwd. Is something wrong in my interpretation ?

Thanks for marking success for the task.

Regards,
Munjal

Hi @munjalbarasara

Your answer is correct, this option is used to skip the home directory creation i.e in your case /home/kareem directory was not be created but you still see the default home of user in passwd and that is fine as per requirements mentioned in the question.

1 Like

Thanks for the info. :slight_smile:

How can I get a sudo or user password?

Hi @Surendar

Please look for wiki under project in your KKE dashboard.

hello kindly anybody help me with this i was unable to understand the question.
it shows {username}: {hostname}
which hostname should i login and what should i do.
@Inderpreet @munjalbarasara @swaroopcs88

It’s a fixed now you can continue with this task.

Easiest way to finish this task is to ssh into the correct server and then type the command:
’ $ sudo useradd -M user’
press enter and to check type:
’ $ ls -l /home/user’

Any other commands or checks seem superfluous for this task.
Always remember man command is your friend!

Completed the task successfully.
Thanks @Tej-Singh-Rana @Lachlan

To complete this question, please follow below

$ ssh -J host1(update as per question) host2 (
password check as per the url

–>sudo adduser -M username as per the question
then submit the answer

Please don’t provide full solution. Let them try at least. Solutions is not a way to learn.

1 Like