Filesystem Hierarchy Standard Explained

The Filesystem Hierarchy Standard or FHS defines how the directory structure in Linux works, and it’s something that many beginner articles have already been written about. That being said, it’s also still one of the things that confuse beginners the most and therefore questions about it still get asked all of the time. If you were to take a look at the top level of your Linux installation, then you’d see many directories that are defined by this specific standard.

We took the time to go through once again and define usr, etc and all of the others that confound even experienced programmers. That being said, you might see an additional directory or folder you don’t find defined here. Have you ever seen /lost+found at the root of your file structure? That one isn’t defined specifically by the FHS, but it’s created by the ext4 and other file systems to make sure there’s a place to put lost files caught during a consistency check. If you’ve ever had the opportunity to explore an Android phone’s structure, then you might have seen it called LOST.DIR as well.

Spelling out the FHS Folders

/ represents the highest point in your entire directory structure – since Linux uses the same system that Unix does for specifying a directory structure, this is the top of everything and not just a single drive. More than likely, if you’re on a single-user Ubuntu or Fedora system, then you have a big disk partition set to mount here. That disk partition has directories or folders that are up at this high level, but it’s important to remember that you could configure Linux to have a different /home, /bin or other partition if you wanted to so you could set the mount point to one of these directories.

/bin includes most of the essential programs that you’d need to run the most basic Linux interface. You’d find cat, ls, mv, touch and nano here. The name stands for binaries.

/boot contains files needed to boot up your system, like a kernel and the initrd files.

/dev features all of the device files that Linux uses to reference other parts of your system. If you ever formatted a flash drive by typing something like /dev/sdb1 after a mkfs command, then you’ve worked with the files that are in here .They’re all real files, but they’re not files in the conventional sense those coming from a Microsoft environment might understand them. These let you work with drives and other devices by referencing a file name.

/etc features a bunch of system wide configuration files. Many people ask what etc stands for, and as you might except it really does mean et cetera in Latin. While it originally held anything that doesn’t fit anywhere else, the modern Linux FHS instructs programmers only to put configuration files here and never to throw in programs.

/home contains your home directory and possibly the home directories of other users if you have any. You can use ~/ as shorthand for your own home directory, which has to go instead of the root /home directory. For instance, if you were a user named manny, then typing ~/Documents would represent /home/user/manny/Documents and get translated as such. The root user has their home directory tucked away at /root instead of /home/root even if you’re using Ubuntu and have it completely hashed out.

/lib holds the various libraries that programs need to run under the Linux kernel. You might also have a /lib64 directory for 64-bit libraries if you’re running on an amd64-based distribution.

/media holds all the automatically mounted drives you have attached at any given time. If you plug memory cards, flash drives or videodiscs into your machine and they’re automatically opened for you, then they’re getting mounted in the /media directory.

/mnt used to hold all your removable media before automatic mounting became popular in Linux. Now it’s used for anything you mount with a sudo command in a command prompt. You might want to use it for mounting  disk images or ISO files if you ever use a mount -o loop iso command.

/opt includes optional packages you might have installed from outside the regular repositories, which could have something like Google Chrome if you have that browser installed from a Google download. It could also have Skype depending on how you installed it.

/proc is a confusing one for newcomers, because it’s a mount point for a virtual file system that provides a place for files that represent the way that the kernel sees all of the equipment attached to your machine. It’s better to experience it first hand than try to explain it. Try running cat /proc/cpuinfo | more at the command prompt to see what your CPU looks like to the kernel. Notice that the speed of your CPU in MHz doesn’t necessarily match the actual speed of your processor. We ran this on a tiny 32-bit netbook with an older 1.6 GHz single-core processor that was running at 800 MHz. This discrepancy is the kind of thing that makes /proc files so useful. What this is showing is that the Lubuntu distribution is so light on resources that the CPU is running in a slower mode until it needs to make use of the full power of the underlying hardware. That’s why the LXDE desktop environment is so popular with those who rebuild older machines.

/run holds files and directories that describe information regarding the current running instance of Linux. If you reboot, then these files get rebuilt to represent the new instance.

/sbin holds really important system programs that are pretty vital. You’ll find that fsck lives here, since Linux wants to make sure it can always check a partition when something bad happens.

/srv holds site-specific data for servers and version control systems, and you might find that it’s completely empty on your installation.

/sys holds files that describe drivers and define the devices that other parts of the FHS reference.

/tmp gets stuffed full of temporary files created by running programs. It’s often cleared out when you reboot, so files here are considered expendable. If you remember the Temp folder inside of C:\Windows, then know that /tmp serves a somewhat similar purpose in Linux.

/usr has become sort of a catch-all directory that fits binary programs that aren’t considered essential while also holding a ton of read-only user data and configuration files. Many beginners find the usr directory a bit strange because it seems to hold so many configuration files for programs they use all the time.

/var is a place for logs and other variable files that change all the time.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.