Linux File System Explained
Linux file system can act as a major source of confusion for new Linux users. While most people will be familiar with the Windows file system layout, the Linux method can seem very alien. In this article, we’ll have a look at how the Linux file system is laid out and how it works.
The first obvious difference between Linux and Windows file systems is that the Linux filesystem doesn’t show you your disks and partitions. Windows displays all connected drive partitions with the familiar drive letter and colon combination with each partition being its own separate filesystem. For Linux, and the Unix distro, the file system is one single entity where disks and partitions are transparently linked to directories that make up parts of that filesystem. This means that the user is unaware of which drive or partition that the file may be stored on.
Linux Directories
The main filesystem starts with the root, symbolized by “/”, of which there are a number of directories. Some store normal files and directories while others are special. Let’s begin with a look at the normal directories:
/bin – This directory contains application binary files for applications that normal users can run.
/boot – This directory contains files needed for the boot process.
/etc – This directory contains system-wide configuration files.
/home – This directory consists of directories for each user to store their files.
/lib – This directory contains library files that various commands use to function.
/lib64 – This directory contains 64-bit specific library files.
/opt – This directory is called optional and contains third-party applications.
/root – This directory contains user files for the root user.
/run – This directory is used for files related to running processes.
/sbin – This directory contains application binary files for system administration applications.
/tmp – This directory stores temporary data files.
/usr – This directory contains user installed application files.
/var – This directory contains variable data files, which is traditionally where log files are written, user’s mail is stored and website data is located.
One of the more confusing aspects is that applications can be installed into a number of different directories. The applications in /bin and /sbin are important for running the system, with the applications in /sbin requiring superuser access (root or sudo) for use. The /usr directory also contains its own bin and sbin directories, with these applications being ones not essential or important to the running of the system. Applications installed to the directories discussed so far are installed through your Linux distributions repositories. The /opt directory, on the other hand, is for third-party applications manually installed on the system.
Special Directories
Now we will take a look at some of the special directories found on Linux file systems:
/dev – This directory stores files and directories that represent devices on the system.
/media – This directory is used by the system as a place to auto-mount removable media inserted into the computer.
/mnt – This directory is used by system administrators to mount file systems.
/proc – This directory contains files and directories representing the various processes running on the system.
/sys – This directory contains files and directories representing the system’s kernel status.
The contents of the special directories dev, proc and sys, while not actual files and directories can still be navigated and viewed using the normal tools.
The layout of the file system is described in the Filesystem Hierarchy Standard (FHS), which was designed to ensure that any Linux distribution compliant with the standard would provide a consistent file system layout to make management easier. This means that whether you use Ubuntu, CentOS or Arch Linux distributions, you should be able to get a good idea of where to look for a particular file you are after.