Site icon NetworkHunt

The Filesystem Hierarchy Standard (FHS) in Linux

The Filesystem Hierarchy Standard (FHS) in Linux

The Filesystem Hierarchy Standard (FHS) provides a well-organized structure for Linux systems, making it easier for users and administrators to locate and manage files. By understanding the purpose of each directory, you can navigate any Linux distribution, troubleshoot issues effectively, and work more efficiently.

FHS standard ensures consistency across Linux distributions, making it easier for users to navigate and manage files. Kali Linux, like other distributions, follows this structure.


1. Overview of Top-Level Directories

Each directory in Linux has a specific purpose. Below is a detailed explanation of these directories along with examples:

DirectoryPurposeExamples
/bin/Contains essential programs used by all users, including basic system commands./bin/ls: Lists files and directories.
/bin/cp: Copies files.
/boot/Stores files required to boot the system, such as the kernel and bootloader configurations./boot/vmlinuz: The Linux kernel.
/boot/grub/grub.cfg: Bootloader configuration file.
/dev/Contains device files that act as interfaces to hardware devices./dev/sda: Represents the first hard drive.
/dev/null: A special device that discards all input.
/etc/Stores configuration files for the system and applications./etc/hosts: Maps hostnames to IP addresses.
/etc/passwd: Stores user account information.
/home/Contains each user’s personal directory for files and settings./home/kali/: Kali’s personal directory.
/home/john/Downloads: John’s downloads folder.
/lib/Holds shared libraries required by programs in /bin/ and /sbin/./lib/libc.so.6: Standard C library.
/lib/modules/: Kernel modules for hardware drivers.
/media/Mount point for removable devices like USB drives and CDs./media/usb: A mounted USB drive.
/media/cdrom: A mounted CD.
/mnt/Temporary mount point for filesystems, often used for network drives./mnt/share: A temporarily mounted network drive.
/opt/Stores optional software installed by third parties./opt/google/chrome: Google Chrome browser.
/opt/software/: Custom third-party software.
/root/The root user’s personal directory (similar to /home/ for normal users)./root/.bashrc: Configuration file for the root user’s shell.
/run/Holds runtime data that is deleted after a reboot./run/utmp: Tracks logged-in users.
/run/network/: Stores network-related runtime data.
/sbin/Contains system administration programs used by the root user./sbin/reboot: Command to reboot the system.
/sbin/iptables: Firewall management tool.
/srv/Stores data for server applications running on the system./srv/http/: Data served by a web server.
/srv/ftp/: Data for an FTP server.
/tmp/Temporary files created by applications, often emptied on reboot./tmp/file.txt: A temporary file created by a program.
/usr/Stores most user-installed applications and shared libraries./usr/bin/python3: Python interpreter.
/usr/share/icons/: System icons.
/var/Contains variable data like logs, caches, and mail queues./var/log/syslog: System logs.
/var/cache/apt/: Package manager cache.
/proc/A special directory for kernel data, representing system information in real-time./proc/cpuinfo: Information about the CPU.
/proc/meminfo: Memory usage information.
/sys/Similar to /proc/, it exports kernel information and interacts with hardware devices./sys/class/net/: Information about network interfaces.
/sys/block/: Details about storage devices.

2. Understanding Key Directories of Linux

2.1 /bin/ – Essential Programs

Contains basic commands that all users can use, like listing files or copying them e.g., cat, ls, cp. These commands are important for the system to work properly.


2.2 /etc/ – Configuration Files

2.3 /boot – Boot Files

This folder has Boot loader files needed to start the Linux system e.g. kernels, initrd.

Examples:

2.3 /home/ – User Directories
2.4 /dev – Device Files

Examples:

2.5. /etc – Configuration Files

Examples:

2.6. /home – User Files

Examples:

2.7. /lib – Shared Libraries

The /lib directory is an essential part of the Linux file system. It contains:

Examples:


2.8. /media – Removable Devices

Examples:


2.9. /mnt – Temporary Mounts

Example:


2.10. /opt – Optional Software

The /opt directory is used to store optional software or third-party applications that are not part of the default Linux system.

Examples:


2.11. /sbin – System Administration Commands

The /sbin directory contains system binaries, which are programs essential for managing and maintaining the Linux system.

Examples:


2.12. /srv – Server Data

The /srv directory is used to store site-specific data related to services running on the system.

Purpose of /srv:

Examples:


2.13. /tmp – Temporary Files

The /tmp directory is used to store temporary files created by the system or users.

Example:


2.14. /usr – User Programs

The /usr directory is a secondary hierarchy in Linux used for read-only user data.

Examples:

2.15. /var – variable

The /var directory stands for “variable”, and it stores files that change frequently during the operation of the system.


3. Kernel-Specific Directories

3.1 /proc/ – Process Information
3.2 /sys/ – System Information

Why is FHS Important?

  1. Consistency: Makes it easier to switch between Linux distributions.
  2. Efficiency: Organizes files logically, saving time in navigation.
  3. Compatibility: Ensures third-party applications know where to find necessary files.

Exit mobile version