Examine the nsswitch.conf file, which the system uses to convert host names to IP addresses and back.
Name service allows a system to convert host names to IP addresses and back. Name service comes into play, for example, when a user types
to open a
connection. At this point, the telnet program makes a system call to the resolver library
The resolver library is a package of subroutines, usually implemented as a shared-object library, that convert host names to IP addresses. In our example, the resolver library converts
to a numeric IP address.
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
The getent command is a very useful way to quickly list users or groups on your system, and the output can be filtered or sorted as required with the grep and sort
commands. For example, if we want to see all configured groups on our system that start with the letter u and have only one additional character in their names, we can use the following command: