Linux Basics: Filesystem Hierarchy (FHS) & Core CLI
1. Why Does This Matter?
Section titled “1. Why Does This Matter?”Coming from Windows, almost every beginner asks: “Where did C:\ and D:\ go? If I install Nginx, where are its config files and error logs stored?”
Real servers rarely have a graphical file manager. Every task—checking configuration, inspecting logs during an outage, or freeing disk space—happens through the Filesystem Hierarchy Standard (FHS) and the Command-Line Interface (CLI).
2. Core Concepts
Section titled “2. Core Concepts”Everything Starts at Root (/)
Section titled “Everything Starts at Root (/)”Instead of separate drive letters, Linux organizes the entire system as one unified directory tree starting at / (pronounced root). Additional disks, USB drives, or volumes are attached (mounted) under directories inside /.
flowchart TD
ROOT["/ (Root Directory)"]
ROOT --> ETC["/etc (System & Service Configs)"]
ROOT --> VAR["/var (Variable Data: logs, cache, web)"]
ROOT --> HOME["/home (Personal User Directories)"]
ROOT --> USR["/usr (Installed Programs & Libraries)"]
ROOT --> TMP["/tmp (Temporary Files, cleared on reboot)"]
ROOT --> PROC["/proc (Virtual Kernel & Process Info)"]
VAR --> LOG["/var/log (System & Application Logs)"]
Most Visited Directories by SysAdmins
Section titled “Most Visited Directories by SysAdmins”| Path | Practical Purpose | Common Examples |
|---|---|---|
/ |
Top-level root of the entire filesystem. | Starting point for all absolute paths. |
/home/<user> |
Home directory for regular users (shortcut: ~). |
/home/ubuntu, stores scripts and personal SSH keys. |
/root |
Home directory for the root superuser. |
Distinct from / — do not confuse the two. |
/etc |
Host-specific system and service configuration files. | /etc/nginx/nginx.conf, /etc/ssh/sshd_config. |
/var/log |
Logs generated by the OS and running services. | /var/log/syslog, /var/log/nginx/error.log. |
/usr/bin |
User-executable command binaries. | git, curl, python3. |
/tmp |
Temporary workspace shared by apps and users. | Scratch files during installs. |
3. Step-by-Step Hands-On
Section titled “3. Step-by-Step Hands-On”Navigating & Inspecting (pwd, ls, cd)
Section titled “Navigating & Inspecting (pwd, ls, cd)”pwdls -lacd /var/logls -lhcd ~Flag breakdown:
pwd: Prints your current working directory.ls -la:-lshows long format (permissions, owner, size, timestamp);-aincludes hidden dotfiles such as.bashrc.ls -lh:-hprints human-readable file sizes (KB,MB,GB).cd ~/cd -: Jumps back to your home directory (~) or toggles back to the previous directory (-).
Creating, Copying, Reading Logs & Searching
Section titled “Creating, Copying, Reading Logs & Searching”mkdir -p ~/lab-linux/configs ~/lab-linux/logscat << 'EOF' > ~/lab-linux/logs/app.log2026-11-27 08:00:01 INFO Server started on port 80802026-11-27 08:02:30 WARN Slow query detected (420ms)2026-11-27 08:03:05 ERROR Connection refused to database 127.0.0.1:5432EOF
tail -n 2 ~/lab-linux/logs/app.loggrep -ni "error" ~/lab-linux/logs/app.logfind ~/lab-linux -type f -name "*.log"mkdir -p: Creates nested parent directories safely without failing if they already exist.tail -n 2: Displays the last 2 lines (tail -ffollows live log updates).grep -ni "error": Searches case-insensitively (-i) and prints matching line numbers (-n).
4. Common Pitfalls
Section titled “4. Common Pitfalls”- Linux paths are case-sensitive:
App.logandapp.logare two completely different files. - No CLI Recycle Bin for
rm: Files deleted withrmare removed immediately.
5. Summary & Next Steps
Section titled “5. Summary & Next Steps”Linux CLI Practice ChecklistCompleted!
0/4 completed