Understanding Name Service Switch in Linux

Home > Search

The Name Service Switch configuration file is at /etc/nssswitch.conf. In this file will be lines that list the database name followed by one or more words. In this example, this line tells the system to first use the /etc/hosts file for IP address to hostname resolution, and then use DNS second. If you were to issue command ping -c4 example.com, first the /etc/hosts file would be checked for a line that contains the IP address of example.com.

hosts:  files dns


In this example, the passwd command will first check the /etc/passwd file, and then sss. As an example, if the passwd user1 command is used to update the password for user1, first the /etc/passwd file will be checked for a record for user1, and then use SSSD second.

passwd:  files sss


Notice in this prior examples, that instead of /etc/hosts and /etc/passwd being listed, just the word files was used. When the word files is used, following are the paths to the files that are used.

aliases     /etc/aliases
ethers      /etc/ethers
group       /etc/group
hosts       /etc/hosts
initgroups  /etc/group
netgroup    /etc/netgroup
networks    /etc/networks
passwd      /etc/passwd
protocols   /etc/protocols
publickey   /etc/publickey
rpc         /etc/rpc
services    /etc/services
shadow      /etc/shadow


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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