In DevOps, virtually every task involves filesystem interaction: reading Docker configuration files, mounting volumes, streaming live web server logs, managing file trees, and ensuring build artifacts land in the right directories.
1. The Filesystem Hierarchy Standard (FHS) in Detail
Understanding standard directory locations allows you to immediately locate configuration files and diagnostic logs across any Linux distribution:
| Directory | Purpose in DevOps & Cloud Engineering | Key Files & Subdirectories |
|---|---|---|
/etc | Central repository for all static system and service configurations. | /etc/nginx/nginx.conf, /etc/hosts, /etc/ssh/sshd_config, /etc/resolv.conf |
/var/log | Standard location where system daemons and servers write log files. | /var/log/syslog, /var/log/nginx/access.log, /var/log/auth.log |
/var/lib | State and persistent data for local services and container runtimes. | /var/lib/docker (Docker layers & volumes), /var/lib/postgresql/data |
/proc | Virtual pseudo-filesystem exposing live Linux kernel and process statistics. | /proc/cpuinfo, /proc/meminfo, /proc/<PID>/cmdline |
/dev | Special device nodes representing physical and virtual hardware interfaces. | /dev/null (the bit bucket), /dev/zero, /dev/urandom (cryptographic random data) |
/tmp | Ephemeral scratch directory; wiped automatically upon system reboot. | Temporary build artifacts, socket files, PID locks |
/usr/local/bin | Custom binaries and command-line tools installed by administrators. | Manually downloaded kubectl, helm, terraform or docker-compose binaries |
2. Absolute vs. Relative Paths
In automated scripts (like GitHub Actions, Dockerfiles, or crontabs), the working directory can vary. Always use explicit absolute paths (e.g. /opt/app/start.sh) rather than relative paths (./start.sh) to prevent path-resolution errors.
3. Creating Files and Directories with Brace Expansion
4. Copying and Moving Files Safely
5. File Viewing & Diagnostic Tools
In headless production environments without GUI editors, command-line inspection tools are essential:
cat — Quick Inspection of Short Files
less — Interactive Pager for Large Files
Never use cat on a 500MB log file! Use less to scroll and search without overloading terminal memory:
Essential less Navigation Keys:
- Space / f — Scroll down one page.
- b — Scroll up one page.
- G — Jump to the end of the file.
- g — Jump to the start of the file.
- /
keyword— Search forward for text match. - n — Jump to the next search match.
- N — Jump to the previous search match.
- q — Quit and return to shell prompt.
head and tail — File Boundaries
tail -f and tail -F — Live Log Streaming
Use watch to periodically execute a command and display full-screen output differences:
6. Deletion Safety & Best Practices
There is NO Recycle Bin or Trash folder in the Linux command line. When a file is removed via rm, its inodes are unlinked and data blocks are marked available for overwriting immediately.
Best Practice Safety Habits:
- Never run
rm -rf *inside a directory without confirmingpwdfirst. - Avoid using shell variables in deletion commands without validation (e.g. if
$DIRis empty,rm -rf /$DIRbecomesrm -rf /!). - Dry-run first with
lsto verify the target glob:ls *.bakbefore runningrm *.bak.
Summary
- The Filesystem Hierarchy Standard (FHS) organizes system configs in
/etc, logs in/var/log, and device nodes in/dev. - Always use absolute paths in automation pipelines to avoid working directory ambiguity.
- Use brace expansion (
mkdir -p app/{src,dist,config}) for rapid directory scaffolding. - Use
cp -a(archive mode) to retain file timestamps, permissions, and symlink integrity. - Use
lessfor large files,tail -Ffor live rotating logs, andwatchfor continuous command monitoring.
In the next lesson, you will master text editing in the terminal (nano, vim), searching with grep and find, and stream transformation with sed & awk!