Inspect NSS config with cat /etc/nsswitch.conf
In this final step of this introductory lab, we'll examine the Name Service Switch (NSS) configuration. NSS is a crucial part of how Linux systems determine where to look for information about users, groups, hostnames, and other network-related data.
When a program needs to look up a user's information (like their user ID or home directory), it consults the NSS configuration to know which sources to check and in what order. These sources can include local files (like /etc/passwd
and /etc/group
), DNS, LDAP, or services like SSSD (which we just looked at).
The configuration file for NSS is /etc/nsswitch.conf
. We'll use the cat
command again to view its contents.
Type the following command in your terminal and press Enter:
cat /etc/nsswitch.conf
You will see lines specifying which sources to use for different types of information. Each line starts with the type of information (e.g., passwd
, group
, hosts
) followed by a colon and a list of sources to check.
## /etc/nsswitch.conf
#
## Example configuration of GNU Name Service Switch functionality.
## If you have the `glibc-doc-reference' and `info' packages installed, try:
## `info libc "Name Service Switch"' for information.
passwd: compat systemd
group: compat systemd
shadow: compat
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
In this example output:
passwd: compat systemd
means that when looking up user information, the system should first check sources configured by compat
(often referring to traditional files like /etc/passwd
) and then systemd
.
hosts: files dns
means that when resolving hostnames, the system should first check the local /etc/hosts
file (files
) and then use DNS.
The order of the sources on each line is important, as the system checks them sequentially until it finds the requested information.
Understanding nsswitch.conf
helps you troubleshoot issues related to user logins, hostname resolution, and other identity-related problems by showing you the order in which your system looks up this information.
You've now had a brief look at three key areas related to user management and authentication in Linux: PAM, SSSD, and NSS. This is a foundational step in understanding how your system handles identities and access.
Click Continue to complete this lab.