#12 - Crash Course on the Filesystem Hierarchy Standard

About Episode - Duration: 7 minutes, Published: 2013-08-15

In this episode, I will give you a crash course on the Filesystem Hierarchy Standard (FHS). The Filesystem Hierarchy Standard gives a great overview of what a UNIX-like filesystem should look like, for example, what directories should exist, and what their contents should be.

Download: mp4 or webm

Get notified about future content via the mailing list, follow @jweissig_ on Twitter for episode updates, or use the RSS feed.

Links, Code, and Transcript


In this episode, I will give you a crash course on the Filesystem Hierarchy Standard (FHS). The Filesystem Hierarchy Standard gives a great overview of what a UNIX-like filesystem should look like, for example, what directories should exist, and what their contents should be.

Although, you are probably not going to read the Filesystem Hierarchy Standard end-to-end, it can be a great reference, and once we understand it, it will help us predict the location of various files and directories. Even though this is the standard maintained by the Linux Foundation, many Linux distributions will have their own take on how this will be implemented. Lets jump over to the Wikipedia page for the Filesystem Hierarchy Standard, where there is a great summery of what the root filesystem should look like. I have included links to these documents in the episode nodes below.

Lets take a look at the “Directory Structure” heading. Here will find a listing of the directories under under the root directory slash. I recommend downloading VirtualBox and installing Ubuntu or CentOS, so that you can play around and explore these systems.

Lets quickly review these directories one-by-one, starting with the slash bin directory. It holds commands used by both the sysadmins and normal users. You will find many common commands used for getting around located here.

Next we have the slash boot, this holds everything we need to boot the system, things like your Linux kernel, the initial ramdisk, bit of the boot loader.

Slash dev, is where all our devices are located, things like our hard disks, keyboard, mice, all those types of things. On some systems this will be a virtual filesystem that is created on boot after detecting the devices attached to your system.

This next one is where you will likely spend quite a bit of your time. Slash e-t-c, or as I like to call it, slash et-c, this is where almost all of your system configuration will live. This stores your system wide configuration files, things like the system hostname, network config, all of the configuration file for the services you plan to provide, things like httpd and mysql. You will also find your filesystem mounts defined here, along with the password and group files. This is a very important directory. I could spend the entire episode talking about it, but lets move on.

Next we have the slash home directory, this is typically the default location where users home directories are stored.

Next, we have slash lib, and possibly slash lib64, if you have a 64-bit machine. These directories will store shared libraries for your system.

These next couple directories will typically hold filesystem mounts for removable media, for example, say a USB stick or something like that.

If you install external packages from source, you might put the in slash opt, say for example, if they do not integrate well with the rest of your system. This is kind of a toss up, and generally up to your personal discretion.

Next we have a virtual filesystem called slash proc, you can explore and change many aspects of the running kernel, for example, changing network settings on the fly, or review running process information, things like memory consumption.

Next, we have slash root, this is roots home directory.

Then there is the slash s-bin directory, this is very similar to slash bin, in that is hold essential commands, but s-bin is special in that, these are typically for sysadmin type things, for example, commands for formatting disks, changing networking settings, or rebooting the system.

Then there is the slash s-r-v directory, you might host content here, which you can serve up over the network. Say for example, a git repository, some NFS mounts, or even web content.

Slash tmp is where you can store temporary files, the operating system will also store things in here too. There will probably be a process running in the background on your system, which will prune older files, so do not store anything in here which you really need access to, hence the temporary name.

Slash user and below, is where the majority of your user land applications and utilities will live. Things like your mysql server or httpd binaries will be store in this directory structure.

Next we have slash var, this is where much of the state information lives, things like log files, mail spools, databases used by the system, and also process lock files.

I know this seems like a lot of material to remember, so to reinforce this, I recommend downloading VirtualBox and installing Ubuntu or CentOS, so that you can play around and explore these systems.