Pcornel
Linux

Users & Groups

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

Back to the Topic

Answer

Users and groups map names to numeric UIDs and GIDs that the kernel uses for every permission check. Accounts come from /etc/passwd, /etc/group and /etc/shadow, or from a directory service via SSSD/winbind.

Remember

The kernel checks numbers, not names. New group membership applies only to new logins. Use getent to see both local and directory accounts. Grant admin rights through sudoers groups.

First checks

  • id <user> — UID, GID and groups
  • getent passwd <user> — account entry
  • getent group <group> — group members
  • sudo -l -U <user> — sudo rights

Commands

sudo
Run an allowed command as another identity according to sudo policy and authentication state.
useradd
Create a local user account and its account-database attributes.
usermod
Modify an existing local user account, groups, identifiers or login properties.
userdel
Remove a local user account and optionally its home or mail data.
groupadd
Create a local group entry with an assigned or automatic group identifier.
passwd
Change password credentials or password-aging and account-lock state.
su
Start a shell or command under another user identity after authentication or policy checks.
getent
sudo -l

Verify in this order

name → passwd/directory lookup → UID/GID and groups → kernel permission checks → sudo rules

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

Confirmation

Confirm action

Continue?