Bootstrap FreeKB - Linux Commands - id command
Linux Commands - id command

Updated:   |  Linux Commands articles

There are a few commands that can be used to determine if a user account exists.

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 Buy Me A Coffee



Comments


Add a Comment


Please enter 5be660 in the box below so that we can be sure you are a human.