A Single File to Remember for Linux Users and Groups

Long story short:
I'm currently prepping for the Linux System Administrator certification, and honestly—keeping track of all the Linux files and commands is a bit overwhelming.

So in this post, I want to focus on just one file that (in my opinion) stands out when it comes to understanding how Linux handles users and groups.


TL;DR

The file to remember is:

/etc/nsswitch.conf

Why This File?

Let's peek at the manual page for this file:

man nsswitch.conf

You'll see something like this:

nsswitch.conf(5)     File Formats Manual

nsswitch.conf(5)

NAME
       nsswitch.conf - Name Service Switch configuration file

DESCRIPTION
       The  Name  Service  Switch  (NSS)  configuration file, /etc/nsswitch.conf ...

Now scroll down to the FILES section, and here's what we get:

The following files are read when "files" source is specified for respective databases:

       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

This section lists all the files that Name Service Switch (NSS) checks when the source is set to "files"—including user and group information.


So... What Is Name Service Switch?

Before NSS, every program had to be coded to look for data in one specific place, such as /etc/passwd.

But modern Linux systems might store user and group info in different sources:

Now imagine having to rewrite every tool to handle each of these sources separately. That would be a lot of work.

NSS solves that.

It gives Linux a unified, flexible way to look up information, in the order you decide, all configured in one place:
/etc/nsswitch.conf


What NSS Solves


In short: if you're trying to understand how Linux decides where to look for things like users, groups, or hosts—start with /etc/nsswitch.conf. It's the glue that ties it all together.