Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Linux User and Group Management Cheat Sheet

Linux User and Group Management Cheat Sheet

Back to Operating Systems and CLI
Updated 2026-05-21
Next Topic: macOS Usage Cheat Sheet

Linux user and group management is the foundation of access control on every Linux system β€” governing who can log in, which resources they can reach, and under what conditions they can elevate privilege. Every process runs as a UID and one or more GIDs; every file has an owner and group; every sudo rule, ACL entry, and PAM policy traces directly back to these identities. The critical mental model is that identity is layered: the kernel cares only about numeric UIDs and GIDs, the database files (/etc/passwd, /etc/shadow, /etc/group, /etc/gshadow) map those numbers to names, and higher-level tools (PAM, SSSD, sudo) bolt additional policy on top β€” misunderstand the layer and troubleshooting becomes guesswork.

What This Cheat Sheet Covers

This topic spans 15 focused tables and 149 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core User Commands (useradd / usermod / userdel)Table 2: Account Database FilesTable 3: Password and Account Aging (passwd / chage)Table 4: login.defs and useradd DefaultsTable 5: /etc/skel β€” Skeleton DirectoryTable 6: Group Management (groupadd / groupmod / groupdel / gpasswd)Table 7: sudo and /etc/sudoersTable 8: PAM (Pluggable Authentication Modules)Table 9: SSH-Based User AccessTable 10: Identity Switching (su / runuser)Table 11: Auditing and Login HistoryTable 12: Access Control Lists (setfacl / getfacl)Table 13: LDAP/AD Integration with SSSDTable 14: Troubleshooting Permissions and Access DeniedTable 15: Security Best Practices β€” Least Privilege

Table 1: Core User Commands (useradd / usermod / userdel)

Creating, modifying, and deleting local user accounts is done with the shadow-utils trio useradd, usermod, and userdel. These commands write directly to /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow, and their behaviour is governed by defaults in /etc/login.defs and /etc/default/useradd.

CommandExampleDescription
useradd -m -s
useradd -m -s /bin/bash alice
β€’ Creates user alice with home directory (-m) and login shell
β€’ home is populated from /etc/skel.
useradd -r
useradd -r -s /usr/sbin/nologin svcacct
β€’ Creates a system account (UID in SYS_UID_MIN–SYS_UID_MAX range)
β€’ no aging info written to /etc/shadow
β€’ no home by default
useradd -u -g -G
useradd -u 1500 -g staff -G sudo,docker alice
Sets explicit UID, primary group (-g), and supplementary groups (-G) at creation time.
useradd -e
useradd -e 2025-12-31 contractor
β€’ Sets account expiration date in YYYY-MM-DD format
β€’ account becomes inaccessible after that date
useradd -D
useradd -D
Displays (or modifies with extra flags) the defaults stored in /etc/default/useradd.
usermod -aG
usermod -aG docker alice
β€’ Appends alice to the docker supplementary group without removing her from existing groups
β€’ omitting -a replaces all supplementary groups
usermod -g
usermod -g staff alice
β€’ Changes alice's primary group
β€’ files in her home dir owned by the old GID are re-owned automatically
usermod -s
usermod -s /bin/zsh alice
β€’ Changes the login shell
β€’ an empty string restores the system default

More in Operating Systems and CLI

  • Linux Text Processing with grep, sed, and awk Cheat Sheet
  • macOS Usage Cheat Sheet
  • AWS CLI Cheat Sheet
  • GCP CLI Cheat Sheet
  • macOS Usage Cheat Sheet
  • systemd and Linux Service Management Cheat Sheet
View all 48 topics in Operating Systems and CLI