Linux FHS

FHS - File Hierarchy Standard

Linux FHS - File Hierarchy Standard


The FHS (File Hierarchy Standard) defines the directory structure and directory contents of Linux Systems. The FHS is maintained by the Linux Foundation. Most modern Linux distributions follow the FHS standards.

In the FHS, all files and directories appear under the root directory "/".



FHS Directory Structure


Directory Description
/ Root directory of the entire file system hierarchy
/bin Essential command binaries
/boot Boot loader files.
/dev Device Files
/etc Host specific system wide configuration files
/home Users home directories
/lib Libraries essential for /bin and /sbin
/media Mount points for removable media
/mnt temporary mounted file systems
/opt Optional application software packages
/proc virtual filesystem containing information about processes, kernel files (procfs mount)
/root Home directory for the root user
/sbin Essential system binaries
/srv Site specific data
/tmp Temporary files.
/usr Secondary hierarchy for read only user data
/usr/bin Non Essential command binaries
/usr/include Standard include files
/usr/lib Libraries for the binaries in /usr/bin and /usr/sbin
/usr/lib Libraries for the binaries in /usr/bin and /usr/sbin
/usr/local Local data. Normally contains sub-directories bin/, share/
/usr/sbin Non Essential system binaries
/usr/share Architecture shared independent data
/usr/src Kernel source code
/var Variable files such as log files, spool files, temporary email files.
/var/cache Application cache files
/var/lock Lock files
/var/log Various log files
/var/mail Users mail boxes
/var/run Information about running system since last boot
/var/spool Spool for task waiting to be processes - print queues - unread mail
/var/tmp Temporary files preserved between boots


The OS Kernel: /boot


The /boot directory contains the actual operating system. Inside this directory, you will find the Linux kernel "vmlinuz". Here, you will also find various files for your systems bootloader. On older systems these may be "Lilo" and on newer systems, these will be "GRUB". We will cover bootloaders in a later topic.


General Utility programs: /bin


Here you will find many important system files that are required for your system to boot. You will also find files that can help recover your system. None essential programs that are not required for system repair or during the boot of your system should be held in "/usr/bin".


System Binaries: /sbin


This area contains programs that are again necessary to boot or repair a damages system. These files are generally used only by the "root" user for system configuration and administration purposes. Some programs here can be used by normal users, however, they are unable to make changes to the system.


System Libraries: /lib


This is the home of shared libraries. Programs in /bin and /sbin will share code that is stored here.


Devices: /dev


Device files provide the connecting mechanism between the shell and the device drivers within the kernel. Within this area devices are refereed to as either "block" or "character" devices. These devices are easily identified by their label of a "c" or "b". (see exert below from the /dev area):


crw-rw-rw- 1 root root 1, 3 Feb 2 20:20 null
brw-rw---- 1 root disk 8, 0 Feb 2 20:20 sda
brw-rw---- 1 root disk 8, 1 Feb 2 20:20 sda1
brw-rw---- 1 root disk 8, 2 Feb 2 20:20 sda2
brw-rw---- 1 root disk 8, 5 Feb 2 20:20 sda5
brw-rw---- 1 root disk 8, 16 Feb 2 20:20 sdb
brw-rw---- 1 root disk 8, 32 Feb 2 20:20 sdc
brw-rw---- 1 root disk 8, 48 Feb 2 20:20 sdd
brw-rw---- 1 root disk 8, 64 Feb 2 20:20 sde
brw-rw---- 1 root disk 8, 80 Feb 2 20:20 sdf
crw-rw----+ 1 root cdrom 21, 0 Feb 2 20:20 sg0
crw-rw---- 1 root disk 21, 1 Feb 2 20:20 sg1
crw-rw---- 1 root disk 21, 2 Feb 2 20:20 sg2
crw-rw---- 1 root disk 21, 3 Feb 2 20:20 sg3
crw-rw---- 1 root disk 21, 4 Feb 2 20:20 sg4
crw-rw---- 1 root disk 21, 5 Feb 2 20:20 sg5
crw-rw---- 1 root disk 21, 6 Feb 2 20:20 sg6


You will notice that their is no file size information listed. Instead you will find two numbers. The first number "the major device" specifies the device type and which kernel driver is in charge of this device. The second number indicates "the minor device". This number distinguishes between similar devices such as disk partitions. In the above example, we can see that our SCSI disks are identified by a major number of "8" (scsi) and the minor number identifies the partitions(sda1, sda2 and sda5).

Within the "/dev" area there are also some very important pseudo devices. Most notably "/dev/null". This is often used to discard output that would normally be directed to your screen. Other devices such as /dev/zero used by the "dd" command also can be found here.


Configuration Files: /etc


This is the main configuration area for the majority of programs. Import startup files such as such as "/etc/fstab", "/etc/inittab" and "/etc/init.d/*" are kept here. Many other import files can be found here. These files allow read access by normal users (with the exception of /etc/shadow), however, only "root" in the majority of cases can make changes.


Optional: /opt>


This area is generally used for third part software installations.


Process info: /proc


This area contains a plethora of information regarding running processes, kernel information, modules. This file system is not a real filesystem as such. No space is taken up on disk by information. More information on this special filesystem can be found here: Understanding Procfs


/sys


This again is another special filesystem similar in ways to /proc. This filesystem has appeared since version 2.6 of the Linux kernel. It contains information relating to your hardware.


Variable: /var


This area is often used for containing log files from the system and also from other installed software. Under /var/log, you will find important log files such as dmesg and syslog. These will be covered in more detail later.


Temp Files: /tmp


An area where temp files are stored. Many systems will clear this area out on system start-up.


Server files: /srv


Here you will find files for various web servers, ftp programs.

Full documentation regarding the FHS can be found at the following website: http://www.pathname.com/fhs/