Understanding the Linux File Hierarchy Standard

About: My name is Sahib. I like to program in many languages. Most prominently in Java and C++, however I sometimes do projects in C, and very rarely in VBScript and Batch.
More About InitializeSahib »

For new Linux users, understanding the FHS (the way files are laid out) is not a trivial task.

You could get confused by / and /root, or maybe you think /dev is a directory for developers, or heck, maybe you don't even know what / is!

This instructable aims to put that all to rest.

NOTE: The folders in this 'structable are from my Ubuntu system. As such, they may not reflect your system's layout.

Supplies:

Step 1: /: Where the Magic Happens

/ is the core of the FHS. Everything is here. Every folder, every file, every device, every partition, everything is stored in here. Even the variables UEFI keeps track of could be stored in here. There is no limit to what / can store. (Excluding partition sizes, or course!)

/ is pronounced as "root". So, when you say, "I'm going to change this system's / directory," you actually say, "I'm going to change this system's root directory."

/ is not to be confused with /root, which we'll talk about.

Step 2: /bin and /sbin: Don't Throw It in the /bin, Throw It in /dev/null

(You probably won't get the title.)

/bin is where the critically important programs are kept. By critically important, I mean that if your system is on the verge of dying, you need these programs to run.

/sbin is similar to /bin, but is different in that /sbin stores utilities that are meant for system administrators. (like recreating folders and other system management things)

Step 3: /dev: Mommy, I Deleted My Keyboard!

/dev stands for device, and as such contains a bunch of files that represent your system's devices.

In UNIX, everything is a file. This carries over to Linux too.

This is why in many commands involving disks you see /dev/sda or something of the sort. That is a device file that represents a hard-disk. Hence why it is included in the disk operations.

/dev also holds many streams, which contain endless amounts of information.

/dev/urandom and /dev/random are for random bytes.

/dev/null is the black hole of Unix. Once something goes it, it cannot escape. (This is why you see so many jokes with /dev/null, it basically equates to "the underworld".)

There are, of course, many more things in /dev.

Admin Tip: If someone ever deletes /dev, you can recreate it with the /sbin/MAKEDEV utility.

Step 4: /boot: Hit the Road, Jack!

If you edited your partitions, you probably saw something like "/dev/sda1: /boot". This is where /boot comes in.

Step 8: /mnt: Mnt. Everest

Step 9: /media: Multimedia

/media contains filesystems, USBS, and cd-roms that were automatically mounted by the system, or mounted by the user without specifying a path.

For example, if I right-click the USB on my desktop, and select "Mount", it mounts it in /media, because I couldn't give it an exact path.

Step 10: /opt: I Would Like to Opt Out, Please.

/opt

stands for optional. Some programs break the rules and place their files here.

Usually it's for temporary files that need to stay after a reboot.

Step 11: /proc: Proc-a-doodle-doo

/proc is where processes store their current information.

It is a way for processes to communicate to each other.

Everyone Tip: Don't do anything with /proc.

Step 12: /root: I Don't Think We're Getting to the Root of the Problem...

/root is the home directory for the root user (superuser). The root user has all the permissions and privileges that the system can give. They can do anything from renaming a file in /etc, to wiping out an entire harddrive.

Step 13: /sys: My Sys Keeps Nagging Me!

/sys is where your system's files are stored. This includes things like firmware variables.

Fun Fact: /usr originally had the role of /home, and stored user directories. This is why it was named "usr". Now, it just refers to shared resources, which is why it is usually called "Unix System Resources" or "Unix Shared Resources" or "User System Resources". At this point, /usr doesn't even have an official name. Just name it whatever you want.