Detailed Breakdown of the Linux File System Structure

There seems to be a lot of confusion out there regarding the structure of the Linux File System. Why are certain programs located in /bin while others are in /sbin or /usr/bin?  Why can I save files in one directory and not another?  How can I tell where I should save my files and programs?  Well, I hope to assist in clearing all of that up today!

First, let’s take a look at a graphical representation of the Linux File System:

The first thing we need to talk about is the root directory (/).  It is the directory where all of the other directories in the file system are stored.  The root user is the only one who can write to this directory.  It is not to be confused with /root which is the root user’s home directory!

Within the root directory, you will find the following sub-directories.  I have included some descriptions of each:

1.  /bin

The /bin directory is for User Binaries.  It is where many of the most common Linux commands are stored.  Specifically, this is where the single user mode binaries are stored.

2.  /sbin

This directory is almost exactly like the /bin directory, with one exception.  The binaries here are primarily used by Administrators for system maintenance.

3.  /etc

The configuration files for your programs and operating system are stored in /etc.

4.  /dev

This is where all of the device files are located.  For example, this is the directory that you would call to in order to mount a drive with a command like: mount /dev/sda2 /mnt/backup

5.  /proc

The /proc directory is one of the most interesting in the whole Linux File System.  It is actually its own virtual file system with a massive amount of text information about system processes.

6.  /var

This is where all of the variable files are stored.  Most commonly, this is where log files and web server files are stored.

7.  /tmp

These are simply temporary files.

8.  /usr

Programs installed by single users get stored here.

9.  /home

This is where all of the user home directories are except for the root user’s home directory which is /root.

10.  /boot

The files that make up the boot loader go in /boot.  Everything from boot loader menus, to the actual kernel files are stored here.

11.  /lib

All of the binary files that are located in /bin and /sbin are supported by the library files located in /lib.

12.  /opt

/opt is short for “optional”.  It is the directory where individual vendors can install optional add-on software for the operating system.

13.  /mnt

The /mnt directory is the mount point that system administrators can use to mount file systems temporarily.

14.  /media

The /media directory serves the same purpose as the /mnt directory except it is specifically for removable devices and can be used by non administrators.

15.  /srv

The /srv directory contains server specific service files.