While working on Kodekloud, I was given a task to create a user without a home directory and that even though I did the command wrong, it said that I passed. since I could not go back to the task to redo it, I decided to run it on my redhat software and created two users; one with the command:
useradd -M kunle1 (with the intention of making it not have a home directory) while the other one I used the command: useradd kunle2
inputted password into the two of them and tried checking if the user ‘kunle1’ would throw an error when I use command: cd /home. It didn’t and even gave me the other two users when I used the -ls command.
when I used the command: grep ^kunle1: /etc/passwd for kunle1 and same for kunle2: grep ^kunle2: /etc/passwd but it gave the same type of output.
Now how do I know which user is not having home directory?
Thanks for the response and your valuable inputs. I read them and implemented them. I am very grateful for taking time out of your busy schedule to attend to my request.
here is the result to the command: grep /etc/passwd.
looking at the image, kunle1 was the one I made with the command -M to have not home directory while the kunle2 was created to have directory yet the passwd command generated almost the same thing without any difference.
One thing that I observed was the when I use the ‘su kunle1’ it didnt give me the username but a bash:
Was that because the user does not have a directory that was why the bash was there?