Lab 02: Filesystem Hierarchy (FHS)

Objective

Understand the Linux directory tree: what each top-level directory is for, how to explore it, and why Linux organises files this way. This is the map you'll use for every future lab.

Time: 25 minutes | Level: Foundations | Docker: docker run -it --rm ubuntu:22.04 bash


Step 1: The Root of Everything

ls /

📸 Verified Output:

bin   boot  dev  etc  home  lib  lib32  lib64  libx32
media mnt   opt  proc root  run  sbin   srv    sys  tmp  usr  var

💡 Every file on a Linux system lives under / (the root directory). There are no drive letters like Windows — one unified tree.


Step 2: Explore the Root with Details

ls -la /

📸 Verified Output:

total 56
drwxr-xr-x   1 root root 4096 Mar  5 00:53 .
drwxr-xr-x   1 root root 4096 Mar  5 00:53 ..
-rwxr-xr-x   1 root root    0 Mar  5 00:53 .dockerenv
lrwxrwxrwx   1 root root    7 Feb 10 14:04 bin -> usr/bin
drwxr-xr-x   2 root root 4096 Apr 18  2022 boot
drwxr-xr-x   5 root root  340 Mar  5 00:53 dev
drwxr-xr-x   1 root root 4096 Mar  5 00:53 etc
drwxr-xr-x   2 root root 4096 Apr 18  2022 home
lrwxrwxrwx   1 root root    7 Feb 10 14:04 lib -> usr/lib
drwxr-xr-x   2 root root 4096 Feb 10 14:05 media
drwxr-xr-x   2 root root 4096 Feb 10 14:05 mnt
drwxr-xr-x   2 root root 4096 Feb 10 14:05 opt
dr-xr-xr-x 593 root root    0 Mar  5 00:53 proc
drwx------   2 root root 4096 Feb 10 14:12 root
drwxr-xr-x   5 root root 4096 Feb 10 14:12 run
lrwxrwxrwx   1 root root    8 Feb 10 14:04 sbin -> usr/sbin
drwxr-xr-x   2 root root 4096 Feb 10 14:05 srv
dr-xr-xr-x  13 root root    0 Mar  1 20:13 sys
drwxrwxrwt   2 root root 4096 Feb 10 14:12 tmp
drwxr-xr-x  14 root root 4096 Feb 10 14:05 usr
drwxr-xr-x  11 root root 4096 Feb 10 14:12 var

💡 Notice bin -> usr/bin — this is a symlink. Modern Ubuntu merges /bin into /usr/bin. The l at the start of lrwxrwxrwx tells you it's a symbolic link.


Step 3: The Essential Directories

📸 Verified Output:


Step 4: The /proc Virtual Filesystem

📸 Verified Output:

📸 Verified Output:

💡 /proc is not a real directory on disk — it's a virtual filesystem generated live by the kernel. Reading /proc/cpuinfo actually asks the kernel "what CPU do I have?" in real time.


Step 5: The /etc Directory (System Configuration)

📸 Verified Output:

📸 Verified Output:

📸 Verified Output:


Step 6: The /var Directory (Variable Data)

📸 Verified Output:

💡 /var holds data that changes while the system runs: logs, databases, package caches, mail spools, print queues. A full /var partition will crash your system — a common production incident.


Step 7: The /tmp Directory

📸 Verified Output:

💡 The t in drwxrwxrwt is the sticky bit — anyone can create files in /tmp, but only the owner can delete their own files. Without it, any user could delete any other user's temp files.


Step 8: Capstone — FHS Reference Card

📸 Verified Output:


Summary

Directory
Purpose
Grows?

/etc

Config files

Rarely

/var

Logs, databases, caches

Yes — monitor!

/tmp

Temporary files

Cleared on reboot

/proc

Kernel virtual FS

Not on disk

/usr

Programs and libraries

On install

/home

User data

Yes

Last updated