Deep-Dive
FUNDAMENTALS REFERENCE
Click any layer to explore concepts, commands, and production-tested guidance.
FILESYSTEM HIERARCHY
Where everything lives, and why it's not arbitrary
3 Concepts
| Path | Contains |
/etc | System-wide configuration files |
/var | Variable data — logs, spool files, caches |
/usr | User-installed software & libraries (most of the OS actually lives here) |
/opt | Third-party/manually installed applications |
/proc, /sys | Virtual filesystems — kernel & process state, not real files on disk |
/etc/fstab entry
UUID=a1b2c3 /data ext4 defaults 0 2
Commands
❯mount -a
❯df -hT
❯findmnt /data
Symbolic (soft) link
🔵A pointer to a path — ln -s target link
🔵Breaks ("dangling") if the target is deleted or moved
🔵Can cross filesystems, can link to directories
Hard link
1
ln target link — both names point to the same inode
2
File data isn't freed until every hard link is removed
3
Cannot cross filesystems, cannot link to directories
USERS, GROUPS & PERMISSIONS
rwx isn't complicated — it's just rarely explained properly
3 Concepts
❯ls -l app.sh
-rwxr-xr-- 1 vishal devs 842 app.sh
❯chmod 750 app.sh
❯chown vishal:devs app.sh
Never chmod 777
🔴777 means anyone, anywhere, can read/write/execute — it "fixes" a permission error by removing the security model entirely
🟠The real fix is almost always the correct owner or group, not wider permissions
/etc/sudoers (edit via visudo only)
%devs ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart billing-api
1
Always edit with visudo — it syntax-checks before saving, a broken sudoers file can lock everyone out
2
Scope rules to specific commands, not blanket ALL=(ALL) ALL, wherever possible
The Three Bits
🔵SetUID — executable runs as the file's owner, not the caller (e.g. passwd)
🔵SetGID — new files in a directory inherit the directory's group
🔵Sticky bit — only the file owner can delete, even with group write (e.g. /tmp)
Audit Command
❯find / -perm -4000 -type f 2>/dev/null
PACKAGE MANAGEMENT
How software actually gets onto a Linux box, and stays trustworthy
3 Concepts
| Task | Debian / Ubuntu (apt, .deb) | RHEL / Fedora (dnf, .rpm) |
| Install | apt install nginx | dnf install nginx |
| Update index | apt update | dnf check-update |
| Upgrade all | apt upgrade | dnf upgrade |
| Search | apt search nginx | dnf search nginx |
| Remove | apt remove nginx | dnf remove nginx |
Adding a third-party repo safely
❯curl -fsSL https://repo.example.com/key.gpg | gpg --dearmor -o /etc/apt/keyrings/example.gpg
❯echo "deb [signed-by=/etc/apt/keyrings/example.gpg] https://repo.example.com stable main" | tee /etc/apt/sources.list.d/example.list
❯apt update
🟠Never apt-get install --allow-unauthenticated in production — that's disabling the exact check that stops supply-chain attacks
Use Packages When
🟢A stable version exists in the repo — packages get security patches automatically
Build From Source When
1
You need a specific patch/version not yet packaged
2
Custom compile flags are required (e.g. hardware-specific optimizations)
3
Track it in config management — a hand-built binary nobody remembers building is a liability
PROCESS & SERVICE BASICS
Every running program is a process — here's how to see and control them
3 Concepts
❯ps aux --sort=-%cpu | head
❯ps -ef --forest
❯pstree -p 1
❯top
Common Signals
🔵SIGTERM (15) — polite "please shut down," process can clean up
🔴SIGKILL (9) — immediate termination, no cleanup, last resort
🔵SIGHUP (1) — often used to tell a daemon "reload your config"
Job Control
1
ctrl+z suspends, bg resumes in background, fg brings back to foreground
2
nohup cmd & keeps a job alive after you log out
❯systemctl status nginx
❯systemctl restart nginx
❯systemctl enable nginx
SHELL, SCRIPTING & TEXT PROCESSING
The tools that turn one-off commands into repeatable automation
3 Concepts
backup.sh
#!/usr/bin/env bash
set -euo pipefail
for f in /data/*.log; do
if [[ -s "$f" ]]; then
gzip "$f"
fi
done
🟠set -euo pipefail at the top of every script — exit on error, undefined variable, or failed pipe. This alone prevents most silent script failures.
❯grep -i "error" /var/log/app.log
❯sed -i 's/staging/production/g' config.yaml
❯awk '{sum+=$5} END {print sum}' access.log
Redirection
🔵> overwrites, >> appends, 2>&1 merges stderr into stdout
🔵cmd1 | cmd2 — stdout of cmd1 becomes stdin of cmd2
Environment Variables
1
export VAR=value — makes it visible to child processes
2
.bashrc / .bash_profile — where persistent exports belong
Decision Guide
WHICH PACKAGE MANAGER AM I ON?
A quick lookup for jumping between distro families.
| Distro | Family | Package Manager |
| Ubuntu / Debian | Debian | apt (.deb packages) |
| RHEL / CentOS / Rocky / Alma | Red Hat | dnf / yum (.rpm packages) |
| Fedora | Red Hat | dnf (.rpm packages) |
| Amazon Linux 2023 | Red Hat-based | dnf |
| Alpine | Independent | apk |