Linux – users not found in /etc/passwd

acllinuxuser-accounts

I login to a linux box with username user1 and my home folder is in /home. There is another user named user2 that has its home directory in /opt/data/folder.

If I want to check the list of users I inspect the file /etc/passwd in this simple way

grep user1 /etc/passwd
grep user2 /etc/passwd

I cannot find neither my user, not the other: Why is that?
Is there any other file or command I should look to have a proper list of users?

Best Answer

That is because the users database is stored elsewhere, for example an LDAP. Use getent passwd $USER to resolve your user. Make sure you read nsswitch.conf(5) with command man nsswitch.conf to understand how and where can be users (and some other) databases stored.

Related Question