Skip to content

Linux Basics: Filesystem Hierarchy (FHS) & Core CLI

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).

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)"]
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.
Terminal window
pwd
ls -la
cd /var/log
ls -lh
cd ~

Flag breakdown:

  • pwd: Prints your current working directory.
  • ls -la: -l shows long format (permissions, owner, size, timestamp); -a includes hidden dotfiles such as .bashrc.
  • ls -lh: -h prints 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”
Terminal window
mkdir -p ~/lab-linux/configs ~/lab-linux/logs
cat << 'EOF' > ~/lab-linux/logs/app.log
2026-11-27 08:00:01 INFO Server started on port 8080
2026-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:5432
EOF
tail -n 2 ~/lab-linux/logs/app.log
grep -ni "error" ~/lab-linux/logs/app.log
find ~/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 -f follows live log updates).
  • grep -ni "error": Searches case-insensitively (-i) and prints matching line numbers (-n).
  • Linux paths are case-sensitive: App.log and app.log are two completely different files.
  • No CLI Recycle Bin for rm: Files deleted with rm are removed immediately.
Linux CLI Practice ChecklistCompleted!
0/4 completed