PAM and NSS Foundations
Quick answer
Identity lookup and authentication are separate jobs. NSS helps applications find information about accounts; PAM lets services apply authentication, account, password and session policies. This separation is a useful first step when a login fails.
Prepare the practice environment
Use the chapter fixture described in lab-fixtures/users/README.md. Run setup as a normal user in a disposable Linux environment, enter the printed directory, check pwd, and run export LC_ALL=C; umask 022. Every local example assumes a fresh fixture; examples explicitly marked VM ONLY require an authorized snapshot-backed VM and must not be run in the ordinary fixture. Commands omit the terminal prompt; outputs below are not commands.
How it works
On glibc-based Linux, /etc/nsswitch.conf describes sources and lookup order for databases such as passwd and group; sources can be local or network-backed. getent passwd NAME resolves account metadata through NSS, not just a local file. Linux-PAM is a framework through which participating services invoke configured module stacks; typical phases are auth, account, password and session. A successful account lookup does not prove a valid password, an allowed login, or permission to run a command. PAM configuration under /etc/pam.d can vary; not every program uses PAM. Use non-sensitive, targeted lookups first; leave policy modification to qualified administrators.
Imagine a fictional user whose name resolves correctly, but whose login is rejected. NSS lookup establishes that account metadata is available through the selected source. It does not show whether an authentication method succeeds, whether account policy allows the login, or whether the service can establish a session. Diagnose each stage independently with authorized evidence. The -s files lookup below selects the local files service in the GNU getent implementation; it is not a test of every configured NSS source.
Try the examples
The fixture uses only local files; a real system can list multiple sources and action conditions.
Expected stdout:
passwd: filesgroup: filesgetent -s files passwd root | awk -F: '{print $1, $3}'This GNU getent example explicitly selects the files service and prints only the name and UID of the conventional root account, not password or personal data. No authentication is attempted.
Expected stdout:
root 0This is a simplified conceptual flow for one hypothetical service, not a universal PAM call sequence. Password changes may use a separate password stack.
Expected stdout:
lookup -> auth -> account -> sessionCommon mistakes
Never assume a lookup failure is a bad password, or that successful authentication implies authorization. Do not change PAM/NSS configuration to bypass a login problem; collect authorized diagnostics and preserve access.
Practice
For a fictional user that resolves through NSS but cannot log in, describe separate checks for account policy, authentication and service authorization. Do not inspect real password hashes or edit PAM configuration.
Related references
Study: getent. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
PAM and NSS foundations — Knowledge Check
Apply the lesson concepts to the controlled account fixture.
What does NSS primarily provide here?
What does a successful getent passwd NAME prove?
Which framework supports auth and session module stacks?
What is the first safe response to an unresolved identity?