TechTorch

Location:HOME > Technology > content

Technology

Understanding the Unix/Linux Hierarchical File System

March 02, 2025Technology1116
Understanding the Unix/Linux Hierarchical File System The Unix/Linux h

Understanding the Unix/Linux Hierarchical File System

The Unix/Linux hierarchical file system (HFS) is a fundamental component of any Linux operating system, providing a structured and organized way to manage and access files and directories. This article explains the structure and typical contents of various directories in a standard HFS, using detailed descriptions and examples for clarity.

The Linux File Hierarchy Structure

The Linux File Hierarchy Structure (FHS), defined by the Linux Foundation since 1977, maintains a standard directory structure for Unix-like operating systems. All files and directories in a Linux system start from the root directory, denoted as /, which is the primary hierarchy root.

Key Directories Explained

1. Root (/)

The root directory, /, is the top-level directory starting from which all files and subdirectories are organized. Only the root user has the permission to write to this directory. The root user's home directory is located at /root, which is different from /.

2. Bin (/bin)

Contains essential command binaries that are required for regular user usage and are essential for single-user mode. Common commands, such as ls, cp, cat, and ping, are found here.

3. Boot (/boot)

Includes boot loader files, such as the kernel, vmlinuz, initrd, and grub. An example file here could be vmlinuz-2.6.32-24-generic.

4. Dev (/dev)

Contains essential device files, like /dev/null, /dev/tty1, and /dev/usbmon0. These device files represent various hardware devices connected to the system.

5. Etc (/etc)

This directory holds host-specific system-wide configuration files. Startup and shutdown shell scripts also reside here. Examples include configuration files and scripts used to manage individual services.

6. Home (/home)

User directories where personal files such as documents and settings are stored. Each user has a home directory in the /home directory, e.g., /home/kishlay and /home/kv.

7. Lib (/lib)

Essential libraries required by binaries in /bin and /sbin directories. Libraries are stored with filenames like ld or

8. Media (/media)

A temporary mount directory for removable media, such as CD-ROMs, floppy drives, and CD writers. Examples include /media/cdrom and /media/floppy.

9. Mnt (/mnt)

A temporary mount directory for filesystems that may need to be mounted temporarily by system administrators.

10. Opt (/opt)

A directory for optional application software packages. Additional applications from individual vendors are stored here.

11. Sbin (/sbin)

Contains essential system binaries used by system administrators for maintenance purposes. Examples include iptables, reboot, ifconfig, and swapon.

12. Srv (/srv)

This directory holds service-specific data, such as data and scripts for web servers and FTP servers. For example, /srv/cvs contains CVS-related data.

13. Temp (/tmp)

A temporary files directory where files are often not preserved between system reboots and may be size-restricted. Files here are deleted upon system reboot.

14. Usr (/usr)

A secondary hierarchy for read-only user data, containing most multi-user utilities and applications. It includes binaries, libraries, documentation, and source code for additional programs.

15. Proc (/proc)

A pseudo-filesystem containing process and kernel information as files. It provides dynamic system information and is automatically generated and populated by the system.

Modern Linux distributions now use a /run directory instead of the older /var/run, in compliance with FHS version 3.0. This change addresses issues where the /var/run directory might not be available at early boot. For example, Debian's Wheezy release made similar changes to support this update.