Linux Filesystem Hierarchy
BeginnerEverything in Linux is a file. The Filesystem Hierarchy Standard (FHS) defines a single tree rooted at / — knowing where things live makes you fast on any Linux system.
Overview
Unlike Windows with drive letters (C:\, D:\), Linux has a single root directory tree starting at /. Every device, process, network socket, and configuration file is represented as a file somewhere in this tree. The Filesystem Hierarchy Standard (FHS) defines what goes where: system binaries in /usr/bin, config in /etc, logs in /var/log, user homes in /home, kernel and hardware in /proc and /sys. Knowing this layout means you can navigate any Linux distro (Ubuntu, CentOS, Alpine) without confusion.
The Directory Tree
A mental map of the most important directories and their purpose. You will find yourself in these directories every day as a developer or DevOps engineer.
/ (root)
├── bin/ → essential user binaries (ls, cp, mv, bash) — always available
├── sbin/ → system binaries for root (fdisk, ifconfig, reboot)
├── etc/ → system-wide configuration files (nginx.conf, sshd_config, hosts)
├── home/ → user home directories (/home/akshay, /home/alice)
├── root/ → root user's home directory
├── var/ → variable data: logs, caches, spool files
│ ├── log/ → system and app logs (syslog, nginx/access.log, auth.log)
│ â””── run/ → runtime PID files and sockets
├── tmp/ → temporary files, cleared on reboot
├── usr/ → user programs (the bulk of installed software)
│ ├── bin/ → most user commands (python3, git, vim, curl)
│ ├── lib/ → shared libraries (.so files)
│ â””── local/→ locally compiled software (not managed by package manager)
├── opt/ → optional third-party software (JetBrains, custom installs)
├── proc/ → virtual FS — live kernel and process info (/proc/cpuinfo)
├── sys/ → virtual FS — hardware and kernel parameters (/sys/class/net)
├── dev/ → device files (disks, terminals, /dev/null, /dev/random)
├── lib/ → shared libraries needed by /bin and /sbin
├── boot/ → bootloader and kernel images (vmlinuz, initrd)
â””── mnt/ → temporary mount points for external filesystemsEverything is a File
Linux represents hardware, processes, and kernel state as files. This uniform interface means you can use standard tools (cat, echo, read) on hardware and processes.
# Hardware info as files
cat /proc/cpuinfo # CPU model, cores, flags
cat /proc/meminfo # RAM usage
cat /proc/loadavg # system load average
cat /proc/version # kernel version
# Network interfaces
ls /sys/class/net/ # eth0 lo wlan0
cat /sys/class/net/eth0/speed # interface speed in Mbps
# Device files
ls -la /dev/
# brw-rw---- ... sda ↠block device (hard disk)
# crw-rw-rw- ... null ↠character device (discard output)
# crw-rw-rw- ... random ↠character device (random bytes)
# crw--w---- ... tty1 ↠character device (terminal)
# Discard output by redirecting to /dev/null
./long-script.sh > /dev/null 2>&1 # suppress all output
# Read random bytes (entropy for crypto)
head -c 16 /dev/urandom | xxdNavigating the Filesystem
Master these navigation commands and you will be comfortable on any Linux system within minutes.
# Absolute vs relative paths
cd /etc/nginx # absolute: starts from /
cd ../nginx # relative: go up one dir, then into nginx
cd ~ # go to home directory (/home/username)
cd - # go to previous directory (like Alt+Tab for dirs)
# Exploration
pwd # print working directory
ls -la # list all files including hidden, with permissions
ls -lah # same + human-readable sizes (K, M, G)
tree -L 2 # show directory tree, 2 levels deep
# Finding things
find /etc -name "*.conf" # find all .conf files in /etc
find /var/log -mtime -1 # files modified in last 24 hours
find / -name "nginx" -type f 2>/dev/null # find nginx binary, suppress errors
# Locate (uses a pre-built index — much faster)
updatedb # update the locate database (run as root)
locate nginx.conf # instant search across the whole system
# Which binary will run?
which python3 # /usr/bin/python3
which java # shows PATH-resolved locationKey Points to Remember
- 1Linux has a single directory tree rooted at / — no drive letters.
- 2/etc stores configuration, /var/log stores logs, /home stores user data.
- 3/proc and /sys are virtual filesystems — kernel and hardware state as readable files.
- 4Everything in Linux is represented as a file: disks (/dev/sda), processes (/proc/PID), sockets.
- 5Absolute paths start with /; relative paths start from the current directory.
Interview Questions
Sign in to ask AriaWhat is the purpose of /etc, /var, and /tmp?
What are /proc and /sys in Linux?
Ask Aria about Linux Filesystem Hierarchy
Your personal AI tutor — ask anything about this concept
Revision Status
Personal Notes
Sign in to save personal notes for this topic.
Discussion
Sign in to join the discussion.