Understanding the Linux file system

Watch out! This tutorial is over 4 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

FHS (Filesystem Hierarchy Standard), defines the directory structure and directory contents in Linux operating systems and It is maintained by the Linux Foundation.

If we go to the Linux terminal, root directory “/“, and will execute “dir” command, it will show us what sub-directories we have, indeed they are sub-directories because in Linux an all Unix like systems, the root directory is “/” and all other are sub-directories of “/“:

ow we will explain each of this sub-directories, and will try to give a basic description about, what they are for.

/ – root directory, it is a mount point of a Linux file system, it is the first or top-most directory in a file system hierarchy, a parent directory of all other sub-directories and contains all other directories and files.

/bin – is an abbreviation of Binaries, It contains essential binary files, executable files, It also contains the very basic needed tools that must be available in order to maintain minimal functionality for the purposes of booting or repairing a system, such as cp, mv, rm, cat, ls, etc.

/dev – is a directory for device and some special files, but mostly for the files that are hardware related, when Linux system (mainly udev) detects and identifies any new hardware on boot or (if its a hot-plug devise) any other given time, then system dynamically creates a relative file in /dev sub-directory, /dev sub directory is one of the directories which should never be placed on separate partitions.

/home – User’s home directories, containing saved files, personal settings, etc.

/lib – Container sub-directory library files, essential for binary files located in /binand /sbin directories

/lib64 – Container sub-directory for 64bit library files, in CentOS7/RH7 it is a link to the /usr/lib64 sub-directory.

/mnt – This is a sub-directory for temporarily mounted file-system, such as CD or USB etc.

/proc – Sub-directory contains information about processes, hardware information for them, and currently loaded modules. /proc sub-directory is a dynamic directory, meaning it exists only when Linux is running, when creator Linux system is not booted /proc directory do not exists on the drive.

/srv – Site-specific data served by the system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems, it is relatively new and in file hierarchy system exists from version 2.3.

/tmp – Sub-directory for temporary files, and one of the directory’s which should be on separate partition

/var – Variable files with expected to continuiusly changed content during normal operation of the system, such as logs, spool files, and temporary e-mail files.

/boot – Sub-directory that holds files needed and used in boot process of Linux operating system

/etc – The name stands fro “Editable Text Configuration”, sub directory is used to hold specific system-wide static configuration files.

/media – Mount points for removable media such as CD or a Flash drive

/opt – Sub-directory for optional application software packages

/root – “root” users home directory.

/run – Relatively new sub-directory introduces in 2011, directory is designed to allow applications to store the data they require in order to operate. This includes process IDs, socket information, lock files and all other data which is required at run-time but can’t be stored in /tmp directory.

/sbin – Sub-directory for essential system binaries, such as fsck, init, route, etc.

/sys – It is a part of the Linux’s virtual file system and it is dynamically loaded, meaning it exists only when Linux system is running, and contains information about currently loaded modules/drivers, devices, and some kernel features.

/usr – Abbreviation for “Unix System Resources”, holds read-only user data, contains all the user binaries, their documentation, libraries, header files, etc.