The Essential Guide to the Linux Filesystem

So you’ve stepped into the root directory of a Linux install and are completely lost eh?  Are you wondering what the hell goes in /opt?  We’re here to help.

Root directory of an LMDE install. Above is a screenshot of the root directory in a Linux Mint Debian Edition installation.  I am going to explain what most of those directories are momentarily.  But, first, I must clarify a few things.  Namely, the differences in terminology and organization between Linux and the king of the computer operating system hill, Microsoft Windows.


Windows ↔ Linux Filesystem

Microsoft Windows bases their terminology for managing and organizing files on the filing cabinet.  Files are stored in folders; folders can have folders inside of them, called sub-folders.  Unix based operating systems, such as Linux and OS X, are a bit different.  It’s not a folder, it is a directory.  And it’s not a sub-folder, it’s a sub-directory.  Fortunately, files are still files.


Microsoft Windows also uses the concepts of “drives.”  Each drive is assigned a letter.  The most common drive letter is the ‘C’ drive, which is usually the main drive containing the operating system.  But you can have more drives than that.  Every device and hard drive partition becomes a “drive.”  Each drive then contains a main folder, called the drive’s “root,” that contains the folders, sub-folders, and files.  When speaking, geeks might refer to the “root of the C drive.”  That means the top-level folder of the C drive.

In Linux, there are no “drives” in the Windows sense.  Everything is contained in one all-inclusive directory called root.  Any additional devices or hard drive partitions that you want to access must be “mounted” to a directory within root.  The contents of that device or partition, all its directories, sub-directories, and files, are contained within that folder you mounted to.

In other words, Windows plays fast and loose with the word root.  There are a bunch of roots.  Every drive gets a root.  The Linux root is much more exclusive.  There is one and only one root.  Everything is contained within root.  Root is almighty.  Root is all-powerful.  Root will cut you.  Fear root.


Okay, now that the formalities are out of the way, let’s dive in.


File System Hyer… Hire… Hierarchy?

Yes, file system hierarchy.  I will abbreviate this as FSH from this point forward because I am a geek, and as a geek, I am lazy.  It requires less caffeine to type out FSH than file system hierarchy, and Red Bull ain’t cheap.  Also, hierarchy is awkward to type.

The FSH is a standard, developed and maintained by the Linux Foundation.  Most Linux distributions subscribe to this standard.  Like any good standard or rule set, there are some deviations (“i before e, except after c” except where that isn’t true).  But, most popular distributions conform fairly well with the FSH standard, so we are going to ignore the outliers, and just talk about the FSH.


Root ( / )

As mentioned earlier, root contains everything.  Filesystem organization is often compared to a tree, where each directory is a new branch on the tree, and each file is a leaf.  The root of a filesystem is analogous to the root(s) of the tree.  Everything builds and branches off the root.

Typically, you will not modify anything in the root.  It’s just a stop on the way to where you want to go.  If you find yourself modifying the root, stop and ask yourself if you really want to do that.  It sounds fishy because it’s not FSH-y.  You see what I did there?  FSH is kind of like fish.  So it sounds fishy because it’s not… oh never mind.  Leave root alone and move on.


Binaries ( /bin/ )

This directory contains essential programs, that must be available all the time, regardless of the user or user mode.  Each of these programs is reduced and compiled into a single executable file, called a binary.  Thus the folder name, binaries.  Few Linux users should need to do anything in this directory.


Boot Loader Files ( /boot/ )

This contains the files needed to boot the operating system, such as kernels.  It’s not something the average user will go into or change.  And it is probably best for newcomers to leave it alone.  However, as your Linux proficiency grows, and you start customizing more and more, you may end up here.


Devices ( /dev/ )

This folder contains special device files, which are essentially interfaces for the devices and hardware attached to the computer.  The files in /dev/ are tools which simplify and standardize basic interactions with devices and hardware.

You will probably never change anything in this directory; however, you may refer to the devices in this directory frequently.  For example, when mounting devices and partitions, you often refer to their corresponding file in /dev/.


Editable Text Configuration ( /etc/ )

This directory contains configuration files and settings for every program that is system-wide, as opposed to user specific.  There may be multiple sub-directories within /etc/ such as /etc/opt/ or /etc/apache/.  These sub-directories are used for organizational purposes, but their contents should still comply with the mandate for /etc/.

Originally, ‘etc’ was referred to as the et cetera directory, and contained random items that didn’t really belong anywhere else.  However, its purpose has been narrowed and /etc/ is assigned as the containing directory for configuration files.  As such, /etc/ is now often designated the “Editable Text Configuration” directory or the “Extended Tool Chest” directory to discourage misusing /etc/.  In conversation, most people simply say etc (pronounced “et see”).

If you install a lot of programs, or change the default settings of programs, you will probably edit configuration files stored in /etc/ at some point.


Home ( /home/ )

This directory contains all the user home directories.  Each user’s home directory contains their personal files, settings, and more.  As a user, you will spend most of your life in your own home directory.


Libraries ( /lib/ )

In computing, a library is a collection of related definitions and tools used by other programs.  For example, the people who developed and programmed your music player likely didn’t write the code required to decode and play MP3 files.  Instead, they rely upon a library of code written by other people.  This directory, /lib/, contains any and all libraries required for the programs stored in /bin/ and /sbin/.

It is possible that your device might have multiple library directories where each additional library folder will have a qualifier after the lib part.  For example, if you are running a 64-bit version of Linux, you will probably have a /lib/ directory which contains libraries for 32-bit programs, and a /lib64/ folder which contain libraries for 64-bit programs.

You probably won’t hang out in library directories much.


Media ( /media/ )

This directory is a place to mount removable media items like USB flash drives, CDs, and DVDs.  Linux distributions that automatically mount removable media will typically create a temporary sub-directory for each removable media item and mount it there.


Mount ( /mnt/ )

This directory is for temporarily mounting filesystems.  If you don’t understand that last sentence, you don’t need and won’t hang out in this folder.  If you want to understand that last sentence, check out my article: WTF Is “Mounting a Filesystem?”


Optional ( /opt/ )

This contains application software packages.  For example, if you have the Mozilla Firefox web browser installed, it is likely installed here.  I like to think of this a bit like the “Program Files” folder in Microsoft Windows.  If you are manually compiling and installing software, you might work a little in /opt/.  Most everyone else never touches it.


Processes ( /proc/ )

This is a holding area for information about running processes and other information about the system.  Much like /dev/ contained interfaces for interacting with hardware and devices, /proc/ contains interfaces for interacting with processes and system information.

For example, /proc/cpuinfo is a file containing information about the computer’s processor in many distributions of Linux.

You shouldn’t really be putting anything in this directory, but you may refer to data in it on occasion.


Root User’s Home ( /root/ )

This is the root user’s home directory.  A somewhat common question is why the root user’s home isn’t stored in /home/.  It’s because sometimes the /home/ directory might actually be stored on another partition or even a network share.  If for some reason that partition or network share isn’t available or fails to mount, the root user can still use the system, and, presumably, fix any problems.


System Binaries ( /sbin/ )

This is very similar to the /bin/ directory; however, the binaries stored here typically require root access to run.  /bin/ might contain a binary which lists all the files and sub-directories in a directory.  /sbin/ might contain a binary which mounts a filesystem.  These are upscale, snob binaries.  /bin/ are lower-class, redneck binaries.


Serve ( /srv/ )

Contains data which might be served from the computer to another computer or device.  An example of this might be files needed for a website.  This directory is very often ignored, and its content is instead lumped into /var/.


Temporary ( /tmp/ )

This is the Linux equivalent of a junk drawer.  This is often cleared out upon rebooting the computer.


User ( /usr/ )

A container directory for files and binaries that are used by all users.  The exact contents of this directory varies widely depending on your distribution.  The lines separating some of the other directories and the /usr/ directory and sub-directories is somewhat blurry.

If you want to know more about this directory, you will need to research how your distribution specifically implements it.


Variable ( /var/ )

Contains data which changes frequently.  Things like system logs and print queues are put here.  It occasionally moonlights as a container for often changing things that might otherwise go in /srv/.  For example, websites are often served from a sub-directory in /var/ instead of /srv/.



There is room for interpretation with the official FSH specifications.  As such, not every distribution is identical.  However, this is a solid introduction to Linux file systems, and should help you get around in any Linux distribution regardless of its FSH-iness.

If you have any examples of misuse of the FSH standard in popular Linux distributions, or have some other input, let us know in the comments.  We would like information on inconsistencies to better help newcomers.


Written By

John is a sailing instructor and mechanical engineering student who happens to be a computer geek. To find more information about John, visit his website or find him on social media by clicking on the icons below.

Facebook Twitter Google+ Website

Tags: ,

Join the Conversation!