Linux File System

A file system is basically a way to organise files. Everything within a Linux file system is classed as a file, including things like text documents or directories. The most popular file system in use with Linux today is 'ext4', which is short for the 'Fourth Extended File System', although others are supported.

Ext4 supports files and file systems up to 16 terabytes in size, together with an unlimited number of subdirectories. It is also classed as a journaling file system, where changes that have not yet been committed to the file system's main part are tracked in a data structure known as a "journal". A journal is often a circular log, that once full starts overwriting entries at the beginning. Due to this a journaling file system can be brought back online more quickly after a system failure.

File System Structure

The file system starts at the root, represented by a '/'. Everything directly under the root is a directory. No files or additional folders should be added here by the end user. Below is an explanation of some of these directories, which feature across most Linux distributions.

/bin

The 'bin' directory, short for binaries, is where all the system binaries reside. All of the shell commands, such as 'ls', 'pwd', and 'cat' are present in this directory.

/boot

As the name suggests, this directory contains items used when the system starts up.

/dev

The devices directory contains files that act as interfaces to devices on the system.

/etc

This directory contains configuration files. When an application is installed on the system it will often create a subdirectory within here for its configuration files.

/home

The 'home' directory contains a subdirectory for each user on the system to act as a container for their personal files. The 'root' user is an exception, where its home folder resides at '/root'.

/lib and /lib64

These directories contain any library files required by the system. The 'lib' directory contains 32-bit libraries, whilst 'lib64' contains 64-bit libraries. The OpenSSL library is often found here as it is required by most web browsers, amongst other things.

/mnt

Short for 'mount', the 'mnt' directory is where any manually mounted drives can be added.

/media

This is where removable media, such as USB devices and CD/DVD drives are mounted.

/opt

Here, optional or third-party software packages are installed. It should be noted however, that an alternative location for these packages that is often used is '/usr/local/bin'.

/run

Run-time variable data is stored here, which includes variables and information about the system from a software perspective.

/sbin

Like the 'bin' directory, 'sbin' contains binary executables, however these are specifically for system administration and maintenance.

/srv

The 'srv' or serve directory should contain site-specific data files, such as static web files, scripts, and anthing else a web server, serves up.

/sys

The system directory contains items that are used to interact and manage hardware devices, along with kernel information.

/tmp

Short for 'temporary', this is where any files can be stored on a temporary basis.

/usr

The user folder contains read-only user related programs, utilities and shared resources that are available to all users.

/var

The variables folder stores variable data, such as log files that changes frequently during system operation.