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:
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.
This directory is almost exactly like the /bin directory, with one exception. The binaries here are primarily used by Administrators for system maintenance.
The configuration files for your programs and operating system are stored in /etc.
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
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.
This is where all of the variable files are stored. Most commonly, this is where log files and web server files are stored.
These are simply temporary files.
Programs installed by single users get stored here.
This is where all of the user home directories are except for the root user’s home directory which is /root.
The files that make up the boot loader go in /boot. Everything from boot loader menus, to the actual kernel files are stored here.
All of the binary files that are located in /bin and /sbin are supported by the library files located in /lib.
/opt is short for “optional”. It is the directory where individual vendors can install optional add-on software for the operating system.
The /mnt directory is the mount point that system administrators can use to mount file systems temporarily.
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.
The /srv directory contains server specific service files.