Pcornel
Linux · Users & Groups

/etc/shadow

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

Back to the Topic

Answer

/etc/shadow stores password hashes and ageing data: name:hash:last change:min:max:warn:inactive:expire. Only root can read it.

Remember

A hash starting with ! or * means locked or no password login. Modern hashes start with $y$ (yescrypt) or $6$ (SHA-512). Change ageing with chage. Never copy hashes between systems in clear channels.

First checks

  • passwd -S <user> — password status
  • 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 → hash in shadow checked → ageing and expiry checked → access granted or refused

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=2702

Confirmation

Confirm action

Continue?