• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

User, Group, and Permission Management on Ubuntu

February 9, 2026

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

ConceptStored inPurposeKey Files / Commands
User account/etc/passwdIdentifies a person/process by UID, username, home dir, shelladduser, useradd, usermod, deluser
Group membership/etc/group + /etc/gpasswdDefines secondary groups for shared accessaddgroup, usermod -aG, gpasswd
Password hashes/etc/shadowStores encrypted passwords + aging info (only root readable)passwd, chage
File ownershipinode (ext4, xfs, etc.)UID:GID pair + permission bits (rwxrwxrwx)chown, chmod
Numeric IDskernelKernel 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:

TaskRecommended CommandWhy Preferred in Ubuntu
Create normal usersudo adduser aliceCreates home dir, copies skel, sets password, asks questions
Create system usersudo adduser –system –group –no-create-home nginxNo password, no home, GID = UID by default
Add user to supplementary groupsudo adduser alice docker or sudo usermod -aG docker alice-aG is critical (append, do not replace)
Change primary groupsudo usermod -g developers bobRarely needed; changes ownership of home dir
Lock / unlock accountsudo passwd -l alice / sudo passwd -u aliceDisables password login; SSH keys still work
Set password expirationsudo chage -M 90 -W 7 aliceEnforces 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):

BitOctalNameEffect when set on fileEffect when set on directory
40004setuidProcess runs with file owner’s UIDRarely used
20002setgidProcess runs with file group’s GIDNew files inherit directory’s group
10001stickyOnly owner can delete/rename fileOnly 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

PatternUse CaseImplementation Notes
Private group per userDefault for human usersadduser does this automatically
Shared group for service accessWeb server + app user reading configaddgroup www-data; usermod -aG www-data appuser
DynamicUser for stateless servicesnginx, redis, memcached (when possible)DynamicUser=yes + StateDirectory=nginx
setgid directories for team projectsShared development folderschmod g+s /srv/team-project
Sticky /tmp & /var/tmpPrevent users from deleting others’ tempDefault since ~18.04
Minimal privileges for sudoersOperator accountsUse 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.

Leave a Reply

You must be logged in to post a comment.

Recent Posts

  • Automating Ubuntu Server Provisioning
  • Ubuntu in Virtual Machines and Containers: Configuration and Optimization
  • Troubleshooting Boot and Startup Issues on Ubuntu – Deeper Technical Perspective
  • Monitoring and Observability on Ubuntu Servers – A Deeper Technical Perspective
  • Kernel Management on Ubuntu: Updates, Modules, and Parameters

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot