Linux File System Hierarchy


The Linux File System Hierarchy or FHS (File-system Hierarchy Standard) is a method that defines the file structure of the Linux operating system in which all the directories and subdirectories are organized in an inverted tree structure.
 In the inverted tree structure, the root is at the top of the hierarchy and the branches such as directories and subdirectories are stretch below the root that is why it is called an inverted tree. In Linux, everything is a file even printer and CD-ROM.
This file system was designed to be used by UNIX distribution developers, system implementers, and package developers.


( / ) The Root Directory: All directories, subdirectories, and files are located under ‘root’ which is represented by “/” (forward slash). Some people get confused between “/” and “/root”, well these two are not the same “/” is called a root directory where all other directories and files of the whole system descended and “/root” is just a root user home directory. The only root user has permission to write under this directory while other users have only read permission to this directory. The subdirectories under “/” are used for standardized purposes to organize files by their type and purpose.

(/bin) Essential User Binaries: This directory contains the executable files of Linux shell basic commands such as ls, cp, grep, cat, etc. Most of the programs in this directory are in binary format and they are accessible by all the users.

(/boot) Boot files: This directory contains the file needed in order to start the boot process, such as the kernel initrd (Initial RAM Disk image), Grub files, etc.

(/dev) Device files: This directory contains special device files that are used by the system to access hardware. This directory also contains some special files that are virtual files, not physically on the disk for example /dev/null.

(/etc) Configuration files: This directory contains configuration files specific to the system. This directory contains a services file, password file, networking file, etc. Basically, if you need to make some changes in the system configuration you can find the respective file under this directory.

(/home) User’s home directory: It is the directory where regular users store their personal data and user-specific configuration files. When you create a user on a Linux system, it generates a folder with user-name under /home directory which looks like “/home/user1”.

(/lib & /lib64) Shared libraries: The “/lib” directory contains shared library images which are need by the essential binaries in the “/bin” and “/sbin” directories. The difference between “/lib” and “/lib64” is that 64-bit version of libraries are stored in “/lib64” and 32 bit version of libraries is stored in “/lib”.

(/media) Mount point of removable media: When you connect any removable devices such as USB, DVD, or SD card, the system automatically creates a temporary mount point under this directory.

(/mnt) Mount point: In this directory system administrator has to create a mount point manually. A system administrator can use this directory to mount file systems, NFS, lvm, etc.

(/opt) optional software: The “/opt” directory is used for storing or installing the third party application which is not available in the official repository or proprietary software
.
(/proc) Process & kernel files: This is a special directory that contains information about the currently running process and kernel parameters. This directory is a virtual file system with text information about the system. For example, if you want to check CPU information then refer to the file /proc/cpuinfo.

(/root) Root user home directory: This is a home directory for the administrative superuser root.

(/run) Application state file: The “/run” directory contains runtime data for processes started since the last boot which includes process ID files and lock files, among other things.

(/sbin) System binaries:  The “/sbin” directory is similar to the “/bin” directory, but it contains the binaries that can run only by the superuser or root or sudo user.

(/srv) Service data: The “/srv” is a directory that contains data of varies services provided by the system. The full form of srv is service. If you are running an HTTP web server from your host system, then it is a good practice to store the website data like HTML file under “/srv” (“/srv/www” or “/srv/Http”).

(/sys) Virtual file system (sysfs): The kernel not only export information to “/proc” but also to virtual file system called sysfs. The sysfs file is mounted under “/sys” directory. The sysfs is created to clean up the “/proc” because much of the hardware information has been moved from “/proc” to “sysfs”.

(/tmp) Temporary directory: This directory is for temporary files. In Linux, many applications use this directory to store temporary files. But do note that files that have not been accessed, changed, or modified for 10 days are automatically deleted from this directory. There is another temporary directory inside the “/var” directory that is “/var/tamp”, in which files that have not been accessed, modified, or changed in more than 30 days are automatically get deleted.

(/usr)  User binaries:  This directory contains installed software, shared libraries include files, and static read-only program data. The important point is the four directories in “/” now have identical contents which are located under “/usr” such as,
“/bin” and “/usr/bin”,
“/sbin” and “/usr/sbin”,
“/lib” and “/usr/lib”.
                                                                                                                                         
(/var) Variable: This directory contains variable data specific to the Linux system that should persist between boots. Files that dynamically change like application files “/var/cache”, various log “/var/log”, user mailbox “/var/mail”, outgoing mail queue and print queue “/var/spool”, etc. found under “/var” directory.


No comments:

Post a Comment

Featured Post

Managing user and groups, UID and GID in Linux

What are users in the operating system? A user is a person who accesses or utilizes computer resources or network services. In order to ...

Popular Posts