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:
Directory | Purpose | Examples |
---|---|---|
/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.
- bin Contains programs that are critical for basic system functionality.
- Contains binary executables
- Examples:
ls
: List directory contents.cp
: Copy files and directories.
- Importance: Without
/bin/
, basic operations like listing files or copying data would not work.
2.2 /etc/
– Configuration Files
- etc is the Central location for configuration files that control the behavior of the system and its applications.
- Examples:
/etc/fstab
: Contains information about disk partitions and their mount points./etc/network/interfaces
: Configuration for network interfaces.
- Misconfigurations in
/etc/
can cause critical system issues.
2.3 /boot
– Boot Files
This folder has Boot loader files needed to start the Linux system e.g. kernels, initrd.
Examples:
/boot/vmlinuz
: The Linux kernel (the core part of the system)./boot/grub/grub.cfg
: The settings for the bootloader (the program that starts Linux).
2.3 /home/
– User Directories
- In the home directory, Each user gets a personal directory for storing files, settings, and application data.
- Examples:
/home/kali/Documents
: A folder for documents.~/.bashrc
: A hidden file for customizing the shell environment.
- The tilde (
~
) is a shortcut for the current user’s home directory.
2.4 /dev
– Device Files
- Contains device files that represent hardware like hard drives, USB devices, and printers.
- These files act as a way for the system to communicate with the hardware.
Examples:
/dev/sda
: Represents the first hard disk./dev/null
: A special file that throws away any data written to it.
2.5. /etc
– Configuration Files
- Stores system settings and configuration files for programs.
- Think of this as the control center for the system. It contains-
- System-wide configuration files: These files control the behavior of the system and applications.
- Startup and shutdown scripts: These scripts are used to start or stop specific programs when the system boots up or shuts down.
Examples:
/etc/fstab
: Contains information about the system’s drives and mount points./etc/hosts
: Maps computer names to IP addresses.
2.6. /home
– User Files
- This is where all users have their personal files and folders.
- Each user has their own folder inside
/home
.
Examples:
/home/rohan
: Rohan’s personal folder./home/kali/Documents
: Documents folder for the userkali
.
2.7. /lib
– Shared Libraries
The /lib
directory is an essential part of the Linux file system. It contains:
- Shared libraries that are required by the programs stored in
/bin
and/sbin
. - These libraries are similar to “helpers” that programs use to perform specific functions, like reading files or communicating with hardware.
Examples:
/lib/libc.so.6
: A standard library used by many programs./lib/modules/
: Drivers that allow the system to work with different hardware.
2.8. /media
– Removable Devices
- Used for USB drives, CDs, and other removable storage.
- When you insert a USB or CD, it gets a folder here.
Examples:
/media/usb
: A mounted USB drive./media/cdrom
: A mounted CD.
2.9. /mnt
– Temporary Mounts
- A temporary location where you can manually mount filesystems.
Example:
/mnt/share
: A temporary folder for accessing a shared network drive.
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.
- It contains software packages from vendors or developers who provide applications separately from the system’s package manager.
- This is useful for installing custom or additional software without interfering with system files.
Examples:
/opt/google/chrome
: The Google Chrome browser./opt/software
: Custom software installed by the user.
2.11. /sbin
– System Administration Commands
The /sbin
directory contains system binaries, which are programs essential for managing and maintaining the Linux system.
- These binaries are typically used by system administrators (
root
user). - Unlike
/bin
, most commands in/sbin
are related to system management tasks and are not usually needed by regular users.
Examples:
fsck
: Checks and repairs the filesystem.reboot
: Restarts the system.iptables
: Manages the firewall.
2.12. /srv
– Server Data
The /srv
directory is used to store site-specific data related to services running on the system.
- “srv” stands for service.
- It contains data files, scripts, and resources used by server applications, such as web servers, FTP servers, and version control systems.
Purpose of /srv
:
- To organize and store files served by the system to clients or users.
- Keeps server-related data separate from other system directories.
- Makes it easy to identify and manage server-specific files.
Examples:
/srv/http
: Files served by a web server./srv/ftp
: Files served by an FTP server.
2.13. /tmp
– Temporary Files
The /tmp
directory is used to store temporary files created by the system or users.
- These files are not meant to be permanent.
- Files in
/tmp
are often deleted automatically when the system reboots or after a certain period of time.
Example:
/tmp/test.txt
: A temporary file created by a program.
2.14. /usr
– User Programs
The /usr
directory is a secondary hierarchy in Linux used for read-only user data.
- It contains programs, libraries, documentation, and source code for user-related tasks.
- Most of the applications and utilities installed on the system are found here.
- It complements the root directories like
/bin
and/sbin
.
Examples:
/usr/bin/python3
: Python programming language./usr/share/man/
: Manuals for Linux commands./usr/local
: Software installed manually by users.
2.15. /var
– variable
The /var
directory stands for “variable”, and it stores files that change frequently during the operation of the system.
- It contains data like logs, caches, and other variable files that grow or shrink over time.
- Unlike
/tmp
, the files in/var
are often preserved across reboots.
3. Kernel-Specific Directories
3.1 /proc/
– Process Information
- it provides a virtual filesystem with information about running processes and system resources.
- Examples:
/proc/1234/
: Information about process ID 1234./proc/cpuinfo
: Details about the CPU.
3.2 /sys/
– System Information
- Exports information about hardware devices and allows interaction with them.
- Examples:
/sys/class/net/eth0/
: Information about the Ethernet interface./sys/block/sda/
: Details about the first hard drive.
Why is FHS Important?
- Consistency: Makes it easier to switch between Linux distributions.
- Efficiency: Organizes files logically, saving time in navigation.
- Compatibility: Ensures third-party applications know where to find necessary files.