Pcornel
Linux · Users & Groups

Users

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

Back to the Topic

Answer

A Linux user account has a name, UID, primary group, home directory and login shell (in /etc/passwd) and a password hash (in /etc/shadow). System accounts run services; regular accounts are for people.

Remember

Create with useradd -m -s /bin/bash <user> (or adduser on Debian), set the password with passwd, lock with usermod -L or passwd -l. A shell of /usr/sbin/nologin blocks interactive login. Directory users (LDAP/AD via SSSD) appear in getent but not in /etc/passwd.

First checks

  • chage -l <user> — password ageing and expiry
  • 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

Commands

getent passwd <name>
id alice
getent passwd alice

Verify in this order

account in passwd/directory → password or key valid and not expired → shell allowed → home available → session starts

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

Confirmation

Confirm action

Continue?