Filesystem Hierarchy
100%

The Filesystem · Lesson 1

Filesystem Hierarchy

Learn the intended roles of major Linux directories and how modern merged layouts can differ.

Linux presents mounted filesystems as one directory tree rooted at /. The Filesystem Hierarchy Standard, or FHS, gives many directories conventional roles, but distributions, containers, immutable systems, and local policy can differ. Inspect the actual host before relying on a path.

$ ls -ld /*

Root and Essential System Paths

  • / is the root of the visible filesystem tree.
  • /etc holds host-specific system configuration. It can contain executable helper or startup scripts, so it is inaccurate to say it never contains executable content.
  • /boot holds boot-related files such as boot-loader data and, on many systems, kernels and initial RAM filesystem images.
  • /bin and /sbin traditionally contain essential user and system-administration commands.
  • /lib and architecture-specific variants traditionally contain essential shared libraries and loader components.

Many current distributions use a merged /usr layout in which /bin, /sbin, and /lib are symbolic links into corresponding /usr directories. Use command discovery and package records rather than assuming whether a path is a physical directory or link.

Which directory conventionally contains host-specific system configuration?

Distribution and Local Software

  • /usr contains the main shareable, largely read-only operating-system and application hierarchy, including commands, libraries, and architecture-independent data.
  • /usr/local is reserved for software and data installed by the local administrator outside the distribution's normal /usr management.
  • /opt can hold add-on application packages in self-contained subtrees.

Despite its name, /usr is not where individual users' personal files normally live. Distribution package managers commonly own large parts of it, so copying locally compiled files into /usr/bin can conflict with managed packages.

Which prefix is conventionally reserved for software installed locally outside distribution-managed /usr content?

User and Service Data

  • /home conventionally contains non-root users' home directories, though directory services and local policy can place them elsewhere.
  • /root is the root account's conventional home directory.
  • /srv is intended for site-specific data served by this system.

A home path comes from account information, not merely from joining /home with a username. Use getent passwd USER or the shell's resolved home rather than hard-coding assumptions.

What is the root account's conventional home directory?

Variable, Runtime, and Temporary Data

  • /var contains variable data such as logs, caches, spools, and application state. System logs commonly appear under /var/log, though some systems rely primarily on a journal interface.
  • /run contains volatile runtime state for the current boot, such as sockets, service state, and PID files. It is normally recreated at boot.
  • /tmp is for temporary files and is commonly writable by all users with sticky-bit protection.
  • /var/tmp is intended for temporary files that should survive longer than files in /tmp.

Cleanup policy for /tmp varies; do not assume files persist until reboot or are always deleted at reboot. Applications should use secure temporary-file creation rather than predictable names.

Which path conventionally stores system log files?

Devices, Kernel Interfaces, and Mount Points

  • /dev contains device nodes and related runtime links.
  • /proc exposes process and kernel interfaces through procfs.
  • /sys exposes kernel objects, devices, drivers, and attributes through sysfs.
  • /media is commonly used for automatically mounted removable media.
  • /mnt is a conventional location for temporary administrator mounts.

These are conventions, not permission grants. Mounting another filesystem on a nonempty directory temporarily hides the directory's previous contents until unmounted.

Which path normally exposes the kernel device model through sysfs?

Lesson complete

You finished Filesystem Hierarchy

You can now relate major Linux paths to their intended roles while allowing for real system variation.

  • Start from the unified tree rooted at /.

  • Separate configuration, managed software, local software, and variable data.

  • Distinguish homes and service data from runtime state.

  • Recognize /dev, /proc, and /sys as special runtime interfaces.

  • Inspect symlinks, mounts, account data, and distribution policy before assuming a layout.

Keep your learning progress

Create a free account to save this lesson and continue learning on any device.

Create a free account
Next Lesson
Back to The Filesystem