Pcornel
Linux · Users & Groups

/etc/passwd

Cheat sheet · https://pcornel.dk/topic.php?topic=2701

Back to the Topic

Answer

/etc/passwd lists local accounts, one per line: name:x:UID:GID:comment:home:shell. The x means the password hash is in /etc/shadow. The file is world-readable.

Remember

Edit with usermod or vipw, not a plain editor, to avoid corrupting it. Use getent passwd to include directory users. A shell of /usr/sbin/nologin or /bin/false prevents interactive login.

First checks

  • pwck -r — check passwd/shadow consistency
  • id <user> — UID, primary group and groups
  • getent passwd <user> — account entry (local or directory)
  • getent group <group> — group members
  • sudo -l -U <user> — what the user may run with sudo

Verify in this order

login → name looked up in passwd (or directory) → UID, GID, home and shell taken → password checked in shadow

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2701

Confirmation

Confirm action

Continue?