Pcornel
Linux · Users & Groups

Groups

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

Back to the Topic

Answer

Groups collect users so permissions can be granted once. Each user has one primary group (new files' group) and any number of supplementary groups.

Remember

Add with usermod -aG <group> <user> — without -a the user is removed from other groups. New group membership applies only to new logins (newgrp or log out and in). Service users may need a restart.

First checks

  • 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

sudo
docker
id -nG alice
id -nG

Verify in this order

group created → user added → new login loads the group → files with that group and group permissions are accessible

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

Confirmation

Confirm action

Continue?