Linux Commands - id command
by
Jeremy Canfield |
Updated: November 08 2022
| Linux Commands articles
There are a few commands that can be used to determine if a user account exists.
- The cat command to read the /etc/passwd file
- The id command (this article)
- The getent passwd command
The id command can be used to determine if a user ID exists. This can be preferred over using the cat command to read the /etc/passwd file since the ID command will check for both local user accounts and user accounts that are accessible in LDAP.
In this example, John Doe's user ID is 655 and John Doe is a member of the wheel group.
~]# id john.doe
uid=655(john.doe) gid=2001(wheel) groups=2001(wheel)
Or you can use the UID.
~]# id 655
uid=655(john.doe) gid=2001(wheel) groups=2001(wheel)
Or, you could use the getent passwd command to query multiple sources, such as local user accounts in the /etc/passwd file and LDAP user accounts. In this example, Bush and Clinton are local user accounts, and Reagan and Clinton are users on the LDAP server.
~]# getent passwd
bush:x:1005:1006::/home/ford:/bin/bash
obama:x:1006:1007::/home/carter:/bin/bash
reagan:x:::::
clinton:x:::::
Did you find this article helpful?
If so, consider buying me a coffee over at