Getent
The /usr/bin/getent
command will display a list of entries, Get Entries. The entries are resolved by Name Service Switch Libraries, which are configured in the /etc/nsswitch.conf
file. This file has a list of databases and libraries that will be used to access those databases.
For example, we could use the getent passwd
command to display all users, or getent group
to display all groups. We could extend this though to commands such as getent hosts
to display host file entries and getent aliases
to display user aliases on the system.
The nsswitch.conf
file will define the libraries used to access the passwd
database. On a standard CentOS system, /etc/passwd
is often the only local file, but an enterprise system could include Lightweight Directory Access Protocol (LDAP) modules. In the next chapter, we will learn more using directory services.
We search the /etc/nsswitch
file for the passwd
database using grep
:
# grep passwd /etc/nsswitch.conf
We can see that on my system, we just use...