loading

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.

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.

/boot is incredibly important. Without it, your system wouldn't.... boot. (That's why it's named /boot!)

/boot stores versions of the Linux kernel, initrds, and bootloader files. One single file erased from /boot could destroy your system. (But not brick it.)

Step 5: /etc: Do You Etc What I Etc?

/etc store system-wide configuration files. This means that every user on the system will have the same config, if it is defined in /etc.

A lot of programs (and system services) have their configuration files in /etc.

Some programs keep their configurations in /home, which is where we're going next.

Step 6: /home: There's No Place Like It

/home

is the directory where user's directories are stored.

It's like C:\Users from Windows.

For example, if you had Jacob, Alyssa, and John using the same system, you could have /home/jacob, /home/alyssa, and /home/john.


/home also stores user-wide configs, which means only that user has that configuration.

/home has folders for Documents, the Desktop, etc. A person new to Linux will not have to leave /home that much.

Step 7: /lost+found: Where Did My Shoe Go?

/lost+found is a directory exclusive to some ext filesystems. When you force-shutdown your computer, files that would've been lost otherwise are put into lost+found.

Admin Tip: Don't let users access lost+found. Don't even let yourself access it.

Step 8: /mnt: Mnt. Everest

/mnt is usually where people manually mount filesystems.

/media is where automatically mounted filesystems are usually stored.

/mnt stands for "mount".

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.

Everyone Tip: NEVER EVER EVER EVER EVER EVER EVER EVER DO ANYTHING WITH /SYS.

Step 14: /tmp: It's Fairly Hot Today. the High Will Be 96 Deg- Wrong Temp.

/tmp is where applications keep the temporary files they're using. It is usually mounted as a seperate filesystem, called tmpfs.

Admin Tip: Unless an application is currently using it, it's safe to clear out /tmp.

Step 15: /usr: Whatever Acronym That Has U, S, and R in It

/usr is usually the largest directory in the filesystem.

It contains many subdirectories:

/usr/bin contains system-wide not-as-important binaries

/usr/local/bin contains binaries that aren't pre-installed (sometimes)

/usr/lib contains libraries required by programs in /usr/bin

/usr/local/lib contains libraries required by programs in /usr/local/bin

/usr/share contains documentation of manuals.

I can't name all of them, so I'll stop there.

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.

Step 16: /var: Variably Variously Var

/var contains things like system logs, web servers, printer spools, and other miscellaneous things.

It's called var because it contains variable things. It doesn't have specialized things in it like /boot or /etc. It just has.... stuff.

Step 17: /run: ARE YOU FAST ENOUGH

/run, newly introduced in FHS 3, is the new location for /var/run.

It is similar to /proc in that it contains files that currently running programs need.

Step 18: /lib: But Where Are the Books?

/lib and /lib64 store libraries used by /bin and /sbin binaries.

On my system, lib64 only has one library, ld.so.1 (or something similar).

This is the dynamic linking library for x64 systems.

x64 libraries are found on my system at /usr/lib/x86_64-linux-gnu and /usr/local/lib/x86_64-linux-gnu.

Step 19: /end

This isn't a directory. This is just how I say it's the end of things.


It's the end!

Now you can master the FHS!

About This Instructable

1,005views

18favorites

License:

Bio: 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 ... More »
More by InitializeSahib:Understanding the Linux File Hierarchy Standard Welcome to Autotools: a Portability Solution for Linux Systems How To Compile C and C++ Projects on Windows 
Add instructable to: