File System Hierarchy

Updated: 2020-06-29

Check the list of top level folder by $ ls /:

  • /bin: binaries
  • /boot: boot loader files
  • /dev: device files
  • /etc: configuration files (originally the etcetera directory for files do not belong to other folders)
  • /home: users' home directories
  • /lib: libraries
  • /media: removable media
  • /mnt: mounted file systems
  • /opt: optional application software packages
  • /proc: virtual filesystem providing process and kernel information as files, e.g. $ cat /proc/meminfo or $ cat /proc/cpuinfo. Only available in Linux.
  • /root: root user's home directory
  • /run: run-time variable data, will be cleared at the beginning of the boot process
  • /sbin: essential system binaries, e.g. fsck, init, route
  • /srv: srv=serve, site specific data to be served by the system
  • /sys: information about devices, drivers, and some kernel features
  • /tmp: temporary files
  • /usr: user utilities and applications
  • /var: variable files

/var and /run

/var: contains files to which the system writes data during the course of its operation.

  • /var/cache (contains cached data from application programs),
  • /var/games (contains variable data relating to games in /usr),
  • /var/lib (contains dynamic data libraries and files),
  • /var/lock (contains lock files created by programs to indicate that they are using a particular file or device),
  • /var/log (contains log files),
  • /var/run (contains PIDs and other system information that is valid until the system is booted again) and
  • /var/spool (contains mail, news and printer queues).

After systemd, /run replaces /var/run, will be cleared at the beginning of the boot process.

/run/user/$uid: created by systemd, local to the system, only accessible by the target user, the same as $XDG_RUNTIME_DIR.

/usr vs /usr/local

/usr is for software built elsewhere and then installed on the machine (mostly from your distributions package management system)

/usr/local is for software built locally