π Linux Filesystem Hierarchy β Final Comprehensive Summary¶
π Overview¶
The Linux filesystem is structured as a single inverted tree, starting at the root directory /. Everything (files, devices, sockets, processes) is represented as a file under /.
π Root Directory /¶
The top-level directory containing all system files, user files, devices, and mounts.
π Key Directories Under /¶
1. /bin¶
- Essential user binaries (commands) needed for booting and single-user mode.
- Examples:
ls,cp,mv,cat,grep,bash.
2. /sbin¶
- Essential system binaries for administration, mainly used by root.
- Examples:
init,fsck,ifconfig,reboot.
3. /boot¶
- Files needed for booting the system.
- Kernel (
vmlinuz), initramfs (initrd.img), GRUB files.
4. /dev¶
- Device files (special files that interface with hardware/peripherals).
-
Examples:
/dev/sdaβ first SATA disk/dev/nullβ null device/dev/ttyβ terminal devices
5. /etc¶
- System-wide configuration files.
-
Examples:
/etc/passwdβ user accounts/etc/fstabβ filesystem mount table/etc/hostsβ hostname mappings
6. /home¶
- User home directories.
- Example:
/home/alice,/home/bob
7. /lib, /lib64¶
- Essential shared libraries for programs in
/binand/sbin. -
Examples:
/lib/libc.soβ C library/lib/modulesβ kernel modules
8. /media¶
- Mount point for removable media.
- Examples:
/media/usb,/media/cdrom
9. /mnt¶
- Generic temporary mount point (often used for manual mounts).
- Example:
/mnt/data
10. /opt¶
- Optional or third-party software packages.
- Example:
/opt/google/chrome/
11. /proc¶
- Virtual filesystem providing process and kernel info.
-
Examples:
/proc/cpuinfo/proc/meminfo/proc/[PID]/
12. /root¶
- Home directory of the root user (not
/itself).
13. /run¶
- Volatile runtime data (replaces
/var/runin modern systems). - Example: process IDs, sockets.
14. /srv¶
- Site-specific service data (e.g., web/ftp server files).
- Example:
/srv/www/
15. /sys¶
- Virtual filesystem exposing kernel/device info.
- Example:
/sys/class/net/
16. /tmp¶
- Temporary files (writable by anyone, usually cleared on reboot).
- Example: session files, sockets.
17. /usr¶
- Secondary hierarchy for user applications and read-only data.
-
Often very large.
/usr/binβ non-essential user binaries/usr/sbinβ non-essential system binaries/usr/libβ libraries/usr/includeβ header files/usr/shareβ architecture-independent data (man pages, docs, icons)/usr/localβ locally installed software
18. /var¶
-
Variable files (expected to grow).
/var/logβ log files/var/spoolβ queued tasks (print, mail)/var/tmpβ temp files that persist across reboots/var/cacheβ cached data
π Special Notes¶
- Everything is a file: devices, processes, sockets.
- Hard vs Soft links: Multiple references to files.
- Mount points: Additional filesystems mounted under
/. - Virtual filesystems:
/procand/sysdonβt hold real files, but kernel-generated info.
β Mnemonic Tip:
- bin/sbin β binaries
- etc β configuration
- var β variable data
- usr β user apps
- lib β libraries
- dev β devices
- proc/sys β system + kernel info
π³ Full Directory Tree with Annotations¶
/ # root of the entire filesystem tree
ββ bin/ # essential user commands (ls, cp, mv, cat, bash)
ββ sbin/ # essential system binaries for root (init, reboot, fsck)
ββ boot/ # boot loader + kernel
β ββ vmlinuz # Linux kernel
β ββ initrd.img # initial RAM disk
β ββ grub/ # GRUB bootloader files
ββ dev/ # device files (interface to hardware/peripherals)
β ββ sda # first hard disk
β ββ null # discard output
β ββ tty # terminals
β ββ random # random number generator
ββ etc/ # system-wide configuration files
β ββ passwd # user accounts
β ββ shadow # secure user passwords
β ββ fstab # filesystem mount table
β ββ hosts # static hostname mappings
ββ home/ # user home directories
β ββ alice/ # home dir for user "alice"
β ββ bob/ # home dir for user "bob"
ββ lib/ # essential shared libraries for /bin and /sbin
ββ lib64/ # 64-bit libraries (on 64-bit systems)
ββ media/ # mount points for removable media (USB, CD-ROM)
ββ mnt/ # generic temporary mount point (manual use)
ββ opt/ # optional / third-party software
ββ proc/ # virtual filesystem with process & kernel info
β ββ cpuinfo # CPU details
β ββ meminfo # memory details
β ββ [PID]/ # info for each running process
ββ root/ # root userβs home directory
ββ run/ # volatile runtime data (PID files, sockets) β cleared on reboot
ββ srv/ # service-specific data (web, ftp, etc.)
ββ sys/ # virtual filesystem exposing kernel & device info
ββ tmp/ # temporary files (world-writable, cleared on reboot)
ββ usr/ # user applications and read-only data (very large)
β ββ bin/ # non-essential user commands (awk, gcc, python)
β ββ sbin/ # non-essential system binaries (httpd, named)
β ββ lib/ # libraries for /usr/bin and /usr/sbin
β ββ include/ # header files (C, C++)
β ββ share/ # arch-independent data (docs, man pages, icons)
β ββ local/ # locally installed software (safe from package manager)
ββ var/ # variable data files (changes frequently)
ββ log/ # log files (syslog, dmesg, auth.log)
ββ spool/ # queued tasks (mail, print jobs)
ββ tmp/ # temporary files that persist across reboot
ββ cache/ # application cache data
π Key Principles¶
- Everything is a file: devices, sockets, processes, directories.
- Essential binaries β
/bin,/sbin. - Configuration β
/etc. - User data β
/home. - Variable data β
/var. - Kernel + process info β
/proc,/sys. - Boot files β
/boot. - Temporary storage β
/tmp,/var/tmp. - 3rd party software β
/opt,/usr/local.
β This summary gives you:
- A tree-structured overview (easy to visualize).
- Detailed annotations (purpose + examples).
- A unified cheat sheet for study or quick reference.