How do I know which user has a home directory and which does not?

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?

Thank you

Please see here to understand the /etc/passwd file.

The home directory field should be empty, or may be / (root directory) if you explicitly create a user with no home directory.

Dear @Alistair_KodeKloud,

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.
capture 3

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?

Let’s do an experiment. This is on ubuntu

 useradd --no-create-home testuser

Now read back the user from /etc/passwd and test for existence of home directory

home_dir=$(cat /etc/passwd | grep testuser | cut -d : -f 6)
if [ ! -d "$home_dir" ]
then
    echo "User does not have home directory"
fi

Thus the definition of “without home directory” is that any directory mentioned in /etc/passwd does not exist.

WhatsApp Image 2024-07-08 at 8.44.18 AM
Here in the image is the name it brought forward when I logged into the account using the command ‘su kunle1’

It did not give me my username unlike the kunle2 which brought out the name.