The getent (get entries) command is similar to the cat command, in that it lets you view the contents of a file. However, the getent command is different from the cat command, in that it can query multipe sources. One of the most common uses of the getent command is when a system is configured with both local authentication and LDAP authentication. In this scenario, the local users will be listed in the /etc/passwd file, and the LDAP users will be on the LDAP server. The getent passwd command will display all of the local user accounts in /etc/passwd and all of the users on the LDAP server. 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:::::
Likewise, if a system is configured with both local group accounts and LDAP group accounts, the getent group command will list both local groups and groups on the LDAP server.
~]# getent group group1:x:1001: group2:x:1002: LDAPgroup:x::
Following are a list of common getent commands.