NewCode CLOUD — 20% off your first month on all cloud VPSClaim

User, Group, and Permission Management on Ubuntu

· 4 min read

User, group, and permission management forms one of the foundational security and multi-tenancy mechanisms in Ubuntu (and Linux in general). These systems determine who can access what files, processes, devices, and system resources — and under what conditions.

Ubuntu inherits the classic POSIX discretionary access control (DAC) model from Unix, augmented by modern extensions such as capabilities, namespaces, cgroups, AppArmor profiles, and systemd DynamicUser. Understanding the interplay between these layers is essential for both day-to-day administration and production hardening.

1. Core Concepts

Concept Stored in Purpose Key Files / Commands
User account /etc/passwd Identifies a person/process by UID, username, home dir, shell adduser, useradd, usermod, deluser
Group membership /etc/group + /etc/gpasswd Defines secondary groups for shared access addgroup, usermod -aG, gpasswd
Password hashes /etc/shadow Stores encrypted passwords + aging info (only root readable) passwd, chage
File ownership inode (ext4, xfs, etc.) UID:GID pair + permission bits (rwxrwxrwx) chown, chmod
Numeric IDs kernel Kernel only knows UIDs/GIDs — names are resolved by NSS /etc/nsswitch.conf

Important invariants in 2026-era Ubuntu:

  • UID 0 = root (superuser)
  • UID < 1000 = system accounts (by convention; Debian/Ubuntu policy)
  • UID ≥ 1000 = regular human users
  • GID 0 = root group (very rarely used for files)
  • Primary group usually matches username (private group model)

2. User & Group Management Tools & Philosophy

Ubuntu strongly prefers the high-level, interactive tools from the adduser family over the low-level useradd / groupadd:

Task Recommended Command Why Preferred in Ubuntu
Create normal user sudo adduser alice Creates home dir, copies skel, sets password, asks questions
Create system user sudo adduser –system –group –no-create-home nginx No password, no home, GID = UID by default
Add user to supplementary group sudo adduser alice docker or sudo usermod -aG docker alice -aG is critical (append, do not replace)
Change primary group sudo usermod -g developers bob Rarely needed; changes ownership of home dir
Lock / unlock account sudo passwd -l alice / sudo passwd -u alice Disables password login; SSH keys still work
Set password expiration sudo chage -M 90 -W 7 alice Enforces periodic password change

Modern best practice (2024–2026): Use adduser for humans, adduser –system for daemons, and prefer DynamicUser=yes in systemd units for stateless services (auto-creates ephemeral UID/GID on start, removes on stop — no /etc/passwd pollution).

3. Permission Model – DAC Bits & Special Modes

Standard octal notation: rwxrwxrwx → 7 7 7 = 0777 (dangerous)

Special bits (often overlooked):

Bit Octal Name Effect when set on file Effect when set on directory
4000 4 setuid Process runs with file owner’s UID Rarely used
2000 2 setgid Process runs with file group’s GID New files inherit directory’s group
1000 1 sticky Only owner can delete/rename file Only owner (or file owner) can delete files

Common real-world uses:

  • /usr/bin/passwd → 4755 (setuid root)
  • /var/log → 2755 or 2775 (setgid → logs inherit group)
  • /tmp → 1777 (sticky bit — anyone can write, only owner deletes)

4. Extended Attributes & ACLs

Modern Ubuntu filesystems (ext4, xfs, btrfs) support POSIX ACLs (Access Control Lists) when mounted with acl option.

Basic commands:

Bash
# View ACLs
getfacl /srv/www

# Give bob rw access without changing owner/group
setfacl -m u:bob:rw /srv/www/private

# Default ACL (new files inherit)
setfacl -m d:u:alice:rwx /srv/projects

ACLs are powerful but increase complexity and audit difficulty. Use them sparingly — prefer group membership when possible.

5. Namespaces, Capabilities, and DynamicUser – The Modern Layer

Since ~16.04 and especially in 24.04+, many traditional user/group/permission concerns are replaced or augmented by:

  • User namespaces — processes can have “fake” root inside container/namespace
  • Linux capabilities — granular privileges (CAP_NET_ADMIN, CAP_SYS_ADMIN, etc.) instead of full root → getcap, setcap, capsh
  • DynamicUser= + StateDirectory= in systemd units → Service gets private UID/GID, home in /var/lib/private/<service>, removed on stop
  • ProtectHome=, ProtectSystem=, PrivateTmp=, NoNewPrivileges= — confinement without full sandbox

These mechanisms allow most daemons to run without a static system user in /etc/passwd — reducing attack surface and configuration drift.

6. Practical Production Patterns

Pattern Use Case Implementation Notes
Private group per user Default for human users adduser does this automatically
Shared group for service access Web server + app user reading config addgroup www-data; usermod -aG www-data appuser
DynamicUser for stateless services nginx, redis, memcached (when possible) DynamicUser=yes + StateDirectory=nginx
setgid directories for team projects Shared development folders chmod g+s /srv/team-project
Sticky /tmp & /var/tmp Prevent users from deleting others’ temp Default since ~18.04
Minimal privileges for sudoers Operator accounts Use sudo group + file-based sudoers.d

Summary: Mental Model

Think of Ubuntu’s permission system in four concentric layers:

  1. Kernel enforces numeric UIDs/GIDs — names are just user-space decoration
  2. POSIX DAC (owner/group/other + special bits) — coarse-grained, fast
  3. ACLs — fine-grained exceptions when groups are insufficient
  4. Capabilities + systemd confinement + namespaces — modern, granular replacement for setuid root

The most secure and maintainable servers follow these priorities:

  • Prefer group membership over ACLs
  • Prefer DynamicUser over static system accounts for daemons
  • Prefer capabilities over setuid binaries
  • Keep /etc/passwd and /etc/group as small and boring as possible

Mastering this layered model allows you to move from “chmod 777 to make it work” toward predictable, auditable, and least-privilege access control — the foundation of production-grade Ubuntu servers.

Related articles

More in VPS & ServersServer setup guides