Understanding the Linux filesystem hierarchy

Those of you new to Linux will immediately realise its filesystem varies considerably compared to Microsoft Windows, which can make the transition between the two operating systems even more daunting. While it’s true that Linux has a multitude of different distributions covering just about every conceivable usage, they do commonly share the same core utilities and linux filesystem hierarchy.

At first glance, it does appear rather like a jumbled mess of characters, but every directory has a purpose. To understand this fully we need to split the filesystem into two distinct subjects: filesystem type and filesystem structure.

While Microsoft makes do with NTFS, Linux has multiple filesystem types to choose from. This has resulted in literally hundreds of different versions spawning over the years and the adoption of many proprietary solutions built in-house by major commercial computer makers.

Covering all of them is well beyond the scope of this article, but three of the more common Linux partition types in use today are Btrfs, Ext3 and Ext4. In brief:

  • Btrfs , known as Better FS is a very new filesystem with powerful features similar to Sun’s ZFS filesystem, including features such as snapshots, checksums and on-the-fly compression.
  • Ext3, also known as the Third Extended Filesystem is based on Ext2 but with added journaling capabilities, which aided faster filesystem recovery and added support for POSIX Access Control Lists (ACL).
  • Ext4, is an extension built on the framework provided by previous versions and offers improvements over ext3 as well as increased volume support.  This partition type is one of the most widely used by Linux distributions.

Regardless of which filesystem type you decide to use, or whichever distribution of Linux you decide to try, the Linux filesystem hierarchy in most cases remains the same.

Before we start, those of you experienced with Windows need to be aware that all “\” becomes “/” in Linux. For example, C:\Users\Username in Windows becomes /home/username in Linux.

Understanding the Linux filesystem structure

Below is the main folder layout of the Linux filesystem hierarchy, complete with an explanation of each directory’s purpose:

  • “/” — This is the very top level of filesystem hierarchy, labelled Root.
  • “/bin” — This folder contains system binaries which are crucial for the operation of Linux.
  • “/boot” — The Linux Kernel lives here, often alongside the bootloader software required to start Linux.
  • “/dev” — Linux keeps all of your devices, such as your keyboard and mouse for device access in this directory. Each device has its own folder, like /dev/mouse, for example.
  • “/etc” — System configuration files are located in this directory. For those familiar with Windows it is roughly equivalent to C:\Windows\System32.
  • “/home” — Personal files stored by users are located here inside sub-directories named after each user. In many ways this is comparable to C:\Users\username in Windows.
  • “/lib” — System libraries are kept in this directory. It’s equivalent to C:\Windows\System32.
  • “/lib64” — The 64-bit version of /lib, though this isn’t present in 32-bit versions of Linux.
  • “/media”  — This is an alternative location to mount USB media or network shares and its presence varies.
  • “/mnt” — Short for Mount, more commonly used than the above /media directory.
  • “/opt” — This directory is short for optional software and is where third-party packages are often installed.
  • “/proc” –Special filesystem Linux uses to access processor and kernel information files.
  • “/root” — This is the home directory for the root user, the Linux system administrator account.
  • “/sbin” — In this directory you’ll find system binaries.
  • “/srv” — Contains server files on Linux distros that use this directory.
  • “/sys” — Known as sysfs, this directory contains information about devices and drivers.
  • “/tmp” — Temporary files are stored here, it would be unwise to store files of importance in this location.
  • “/usr” — This directory contains core Linux packages and applications.
  • “/var” — In here you will find files that change often, such as log files, spool files and temporary email files.

The reason that most distributions of Linux maintain a similar directory hierarchy is due in large part to the Filesystem Hierarchy Standard (FHS), maintained by the Linux Foundation, which defines the directory structure and directory contents as used by Linux.



Leave a Reply

Your email address will not be published. Required fields are marked *