Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Concepts

Linux filesystem hierarchy

A guide to the Linux directory layout: what /etc, /var, /usr, /home, /proc, /dev and the rest are for, which are real disks, and which are virtual.

Linux has a single directory tree that starts at / (root). There are no drive letters; extra disks are mounted onto directories of this tree. The Filesystem Hierarchy Standard (FHS) describes what each top-level directory is for, so software and administrators know where to look. Distributions follow it closely, with a few modern twists such as merged /usr.

Knowing the map saves time: configuration is almost always under /etc, logs under /var/log, your files under /home, and anything odd-looking under /proc or /sys is not stored on disk at all.

Terminal
ls /             # the top level
findmnt /        # what is mounted at the root

Try it

Bash Look at the top level

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Virtual versus real

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

The top-level directories

Directory Purpose
/bin, /sbin, /lib, /lib64 Essential programs and libraries. On modern systems these are symlinks into /usr.
/boot Kernel images, initramfs, bootloader files.
/dev Device files: disks (sda), terminals (tty), pseudo-devices (null, zero, urandom).
/etc System-wide configuration, plain text. Nothing here should be a binary.
/home One directory per ordinary user; ~ expands here.
/root Home of the root user, kept apart from /home so it exists when /home is not mounted.
/media, /mnt Mount points for removable media (/media) and temporary manual mounts (/mnt).
/opt Self-contained add-on software, one folder per vendor or product.
/proc Virtual: processes and kernel state as files.
/sys Virtual: devices and drivers exported by the kernel.
/run Runtime state since boot (PID files, sockets); a tmpfs, cleared on reboot.
/srv Data served by this machine (web or FTP content).
/tmp Temporary files, usually cleared on reboot and may be a tmpfs.
/usr The bulk of installed software, read-only in normal use.
/var Variable data that changes while the system runs: logs, caches, spools, databases.

Inside /usr and /var

  • /usr/bin and /usr/sbin: most commands (sbin for administration). /usr/lib holds libraries, /usr/share architecture-independent data (docs, icons, man pages), /usr/include C headers.
  • /usr/local: software installed by you, outside the package manager. Package managers never write here, so upgrades do not clobber it.
  • /var/log: logs. /var/cache: regenerable data. /var/lib: persistent program state (databases, package lists). /var/spool: queued work (mail, print, cron). /var/tmp: temporary files that survive reboots.

Real, virtual and memory-backed

Not everything under / lives on the disk:

  • Disk-backed: /etc, /home, /usr, /var, /boot, /opt.
  • Kernel-generated (virtual): /proc, /sys, /dev (devtmpfs). They show live information and take no disk space.
  • Memory-backed (tmpfs): /run, often /tmp, /dev/shm. Fast, lost at reboot.

Administrators commonly put /home, /var or /srv on their own partitions, so a runaway log cannot fill the root filesystem. See fstab and findmnt.

Usage notes

  • Merged /usr: on current Debian, Ubuntu, Fedora and Arch, /bin, /sbin and /lib are symlinks to /usr/bin, /usr/sbin and /usr/lib. Scripts using #!/bin/bash still work.
  • Where to put your own things: scripts for one user in ~/bin or ~/.local/bin; machine-wide ones in /usr/local/bin; config in /etc/<name> or ~/.config/<name>.
  • Find what owns a path: dpkg -S /path on Debian family, rpm -qf /path on RPM systems.
  • Case sensitive: /etc/Hosts and /etc/hosts are different names.
  • Containers and other distros may differ: NixOS and Guix break the usual layout deliberately; Alpine uses the same top level with BusyBox in /bin.
  • Do not edit /proc or /sys blindly. Writing to some files changes kernel behavior immediately; changes last until reboot unless persisted elsewhere (for example sysctl.d).