file system hierarchy
The file system on most linux systems is organized in a similar way. The layout of the linux file system is defined in the Filesystem Hierarchy Standard, and this file system hierarchy is described in man 7 hier
.
FSH Overview
Directory | Use |
---|---|
/ |
The root directory. This is where the system tree starts. |
/bin |
Contains executable programs that are needed to repair a system in a minimal troubleshooting mode. This directory is essential during boot. |
/boot |
Contains all files and directories that are needed to boot the linux kernel. |
/dev |
Device files that are used for accessing physical devices. This directory is essential during boot. |
/etc |
Contains configuration files that are used by programs and services that are used on your server. This directory is essential during boot. |
/home |
Used for local user home directories. |
/lib, lib64 |
Shared libraries that are used by programs in /boot , /bin , and /sbin . |
/media, /mnt |
Directories that are used for mounting devies in the file system tree. |
/opt |
This directory is used for optional packages that may be installed on your server. |
/proc |
This directory is used by the proc file system. This is a file system structure that gives access to kernel information. |
/root |
The home directory of the root user. |
/run |
Contains process and user specific information that has been created since last boot. |
/sbin |
Like /bin , but for system administration commands that are not necessarily needed by regular users. |
/srv |
Directory that may be used for data that is used by services like NFS, FTP, and HTTP. |
/sys |
Used as an interface to different hardware devices that is managed by the linux kernel and associated processes. |
/tmp |
Contains temporary files that may be deleted without any warning during boot. |
/usr |
Directory that contains subdirectories with program files, libraries for these program files and documentation about them. Typically, many subdirectories exist in this directory that mimic the contents of the / directory. The contents of /usr are not required during boot. |
/var |
Directory that contains files which may change in size dynamically, such as log files, mail boxes, and spool files. |
Mounts
A linux file system is presented as one hierarchy, with the root directory /
as it’s starting point. This hierarchy may be distributed over different devices and even computer systems that are mounted into the root directory.
Mounting devices makes it possible to organize the linux file system in a flexible way. Some directories are commonly mounted on dedicated devices:
/boot
: This directory is often mounted on a separate device because it required essential information your computer needs to boot. As the root directory/
is often on a logical volume manager (LVM) logical volume, from which linux cannot boot, the kernel and associated files need to be stored separately on a dedicated/boot
device./var
: This directory is often on a dedicated device because it grows in a dynamic and uncontrolled way. By putting it on a dedicated device, you can ensure that it will not fill up all storage on your server./home
: This directory often is on a dedicated device for security reasons. By putting it in a dedicated device, it can be mounted with specific options to enhance the security of the server. When reinstalling the operating system, it is an advantage to have home directories in a separate file system. The home directories can then survive the system reinstall./usr
: This directory contains operating system files only, to which normal users normally do not need any write access. Putting it on a dedicated device allows administrators to configure it as a read-only mount.
The mount
command gives an overview of all mounted devices. To get this information, the /proc/mounts
file is read, where the kernel keeps information about all current mounts.
The df -Th
command was designed to show available disk space on mounted devices; it includes most of the system mounts. The -h
option summarizes the output of the command in a human-readable way, and the -T
option shows which file system type is used on the different mounts.
The findmnt
command shows mounts and the relation that exists between the different mounts.