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:
+-------------------------------------------------------------+
| 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:
anupam:x:1000:1000:Anupam Baral,,,:/home/anupam:/bin/bash
[1] [2] [3] [4] [5] [6] [7]| Field | Name | Example Value | Description |
|---|---|---|---|
| [1] | Username | anupam | Unique alphanumeric login name for the account |
| [2] | Password Flag | x | Placeholder indicating encrypted password hash is stored in /etc/shadow |
| [3] | User ID (UID) | 1000 | Numerical user identifier (0 is root; standard users start at 1000) |
| [4] | Group ID (GID) | 1000 | Numerical identifier for user's primary group in /etc/group |
| [5] | GECOS / Comment | Anupam Baral,,, | User full name, room number, or administrative contact notes |
| [6] | Home Directory | /home/anupam | Absolute path to the user's personal home directory |
| [7] | Login Shell | /bin/bash | Default command-line shell initiated upon interactive login |
- `/etc/shadow`: Secure file readable only by root (permission
640or600) 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:
# 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 developer3. 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).
[ 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:
>
> sudo visudo
visudoperforms 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.
# 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