Lesson 4 / 8
Module 2Lesson 2⏱ 50 min study

Lesson 4: User & Group Management, Privilege Delegation (sudo) & Privacy Hardening

Deconstruct Linux multi-user security, manage accounts and shadow passwords, master group memberships, configure the sudoers policy, and enforce network perimeter defense with UFW.

✦ Key Architectural Takeaways
  • •Every Linux process and file is owned by a User ID (UID) and a Group ID (GID); UID 0 is the all-powerful root superuser.
  • •User definitions reside in /etc/passwd, hashed passwords reside in the protected /etc/shadow file, and group memberships reside in /etc/group.
  • •The adduser utility provides an interactive, safe wrapper around useradd, automatically creating home directories, setting permissions, and populating skeleton dotfiles.
  • •Privilege escalation via sudo allows authorized non-root users to execute administrative tasks while maintaining full audit logging in /var/log/auth.log.
  • •The Uncomplicated Firewall (UFW) provides an intuitive frontend to Linux netfilter/iptables, enabling administrators to block unsolicited incoming traffic with one command.

1. The Linux Multi-User Security Model

Linux was engineered from day one as a true multi-tenant, multi-user operating system. Access permissions and system resources are mediated by numerical identifiers:

TEXTSYSTEM SCHEMATIC
+-------------------------------------------------------------+
|                      User Account Types                     |
+-------------------------------------------------------------+
| 1. Superuser (Root)      | UID: 0                           |
|    - Unrestricted system privileges.                        |
+--------------------------+----------------------------------+
| 2. System / Service Users| UID: 1 - 999                     |
|    - Non-interactive accounts used by daemons               |
|      (e.g., www-data, sshd, systemd-network, mysql).        |
+--------------------------+----------------------------------+
| 3. Standard Human Users  | UID: 1000 - 60000                |
|    - Interactive accounts created for desktop and CLI users |
|      (e.g., anupam, developer).                             |
+-------------------------------------------------------------+

Critical Account Database Files

  • `/etc/passwd`: Plaintext file storing user metadata in colon-separated format:
TEXTSYSTEM SCHEMATIC
  anupam:x:1000:1000:Anupam Baral,,,:/home/anupam:/bin/bash
  [1]   [2] [3]  [4]         [5]           [6]        [7]
FieldNameExample ValueDescription
[1]UsernameanupamUnique alphanumeric login name for the account
[2]Password FlagxPlaceholder indicating encrypted password hash is stored in /etc/shadow
[3]User ID (UID)1000Numerical user identifier (0 is root; standard users start at 1000)
[4]Group ID (GID)1000Numerical identifier for user's primary group in /etc/group
[5]GECOS / CommentAnupam Baral,,,User full name, room number, or administrative contact notes
[6]Home Directory/home/anupamAbsolute path to the user's personal home directory
[7]Login Shell/bin/bashDefault command-line shell initiated upon interactive login
  • `/etc/shadow`: Secure file readable only by root (permission 640 or 600) storing salted and cryptographic password hashes (SHA-512) alongside account expiration policies.
  • `/etc/group`: Defines system groups and secondary group memberships.
§

2. User & Group Administration Commands

Modern Debian and Mint distributions provide high-level utilities for user management:

BASHSYSTEM SCHEMATIC
# 1. Create a new user account interactively with home directory and password
sudo adduser developer

# 2. View user details, UID, GID, and active group memberships
id developer

# 3. Add the user to a secondary group (e.g., 'docker' or 'wireshark')
sudo usermod -aG sudo developer

# 4. Lock or unlock an account password
sudo passwd -l developer   # Lock account
sudo passwd -u developer   # Unlock account

# 5. Delete a user account and optionally remove their home directory
sudo deluser --remove-home developer
§

3. Privilege Delegation: The Architecture of sudo

Logging into an interactive desktop directly as the root superuser violates principle-of-least-privilege security. Instead, Linux implements `sudo` (SuperUser DO).

TEXTSYSTEM SCHEMATIC
[ Standard User 'anupam' ]
            |
            v  Types: 'sudo apt update'
+-------------------------------------------------------+
|  sudo binary validates /etc/sudoers policy            |
|  - Is 'anupam' in the 'sudo' group?                   |
|  - Prompt for user's personal password (not root pw!) |
|  - Check timestamp cache (/run/sudo/ts - valid 15m)   |
+-------------------------------------------------------+
            |
            v
[ Command executes with effective UID 0 (root) ]
            |
            v
[ Execution logged to /var/log/auth.log for auditing ]

Editing Sudoers Safely: Never edit the sudo configuration file directly with standard text editors. Always use the `visudo` command:

>

BASHSYSTEM SCHEMATIC
> sudo visudo

visudo performs strict syntax validation before writing changes to disk, preventing syntax errors that could lock all administrators out of root privileges.

§

4. Network Hardening: The Uncomplicated Firewall (UFW)

By default, Linux listens on open network sockets if services (like OpenSSH, Apache, or Samba) are running. UFW (Uncomplicated Firewall) wraps the underlying Linux kernel nftables / iptables engine with concise, human-readable syntax.

BASHSYSTEM SCHEMATIC
# Check current firewall status
sudo ufw status verbose

# Set default security policies: deny all incoming, allow all outgoing
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow specific essential traffic (SSH on port 22)
sudo ufw allow 22/tcp

# Allow web server traffic by service profile
sudo ufw allow "Nginx Full"

# Enable and start the firewall on boot
sudo ufw enable

# Review active firewall rules
sudo ufw status numbered