The Linux File System Hierarchy (FHS)
File System : A file system is an organization of data and metadata on a storage device.
File : A File is a collection of data stored on the disk . It may be a device which reads data or writes data.everything in linux is a file.
Directory : a directory is a collection of files.
A Linux file system is a collection of files and directories stored. Each file system is stored in a separate whole disk partition.Linux File System is structured as
/: root directory (everything comes under this)
We have the following directories under “/”.
/boot: contains the boot loader files usually kernel & init.d files which are important for booting the system
/home: users Home directories which contain personal settings ,files e.t.c
/sbin: contains commands executed by the root user like init,mount,ifconfig e.t.c
/bin: contains commands executed by the normal user like cp,ls,ll e.t.c
/var: contains logs files , variable files(files whose content is changted continuously during the operation of the system).It also holds contents for the ftp,http servers.This is usually give high space.
/dev: contains essential device files(every thing in linux is a file even the devices too, so for cdrom we will have a file ).
/mnt: mount point for remote access and also works as a temporary mounted file systems.
/media: mount point for removable devices like Cdrom, USB e.t.c
/tmp: contains temporary files. Cleared during system reboots.
/etc: perhaps the important directory in linux which contain all the system wide config files.no binaries should be placed in here.
/usr: contains all software packages installed (applications installed by Distributions)
/usr/local: contains applications that are compiled by the user.
/opt: contains all the optional software packages installed.
/srv: service data served by Host.
/misc: Miscellaneous Purpose
/net: Shared mount point for the entire file system.
/lib: contains system libraries that are required to run the system.
/Lost+found: a special directory that is available in every directory. If we have a system Crash, the linux file system checker recovers corrupt files as they get places in here.
The Linux File System is categorised into 2 types depending on the Characteristics of the files
Shareable vs. un shareable
Shareable files can be located on one system and used on another, while unshareable files must reside on the system on which they are used.
Static vs. variable
Static files change only through system administrator intervention, such as installing or upgrading a package, and include documentation, libraries, and binaries. Variable files are all other files, such as logs, spool files, databases, and user data, which are subject to change by users and by system processes.
File HS | ||
Shareable | Unshareable | |
Static | /usr /opt | /etc /boot |
Variable | /var/mail /var/spool/news | /var/run /var/lock |
There was another 2 important location available /proc and /sys.
/proc: Virtual file system containing kernel and process status as text files.This provides us the details of the running system and kernal details.The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime using sysctl command.
/sys: This provides information about the system devices and drivers.It is a ram-based filesystem initially based on ramfs. It is use to exporting kernel objects so that end user can use it easily.
Types of File Systems Supported by Linux
Ext2 : This file system contains blocks,inodes e.tc.
Ext3 : This is enhanced version of ext2 which supports journalling.
Note : journalling allows fast file system recovery
NFS : Network file System
NTFS : Windows File System and many others
Again a File System in linux can be divided into 2 catagories
User Data Which stores acctual user data
Meta Data which stores File System information like super block ,inode e.t.c
The Meta Data describes the structure of the file system like superblock , inode .
Super Block : Each file system is different and they have type like ext2, ext3 etc. Further each file system has size like 5 GB, 10 GB and status such as mount status. In short each file system has a superblock, which contains information about file system such as:
- File system type
- Size
- Status
- Information about other metadata structures
Happy Learning