Linux Directory Structure

Linux directory structure is an essential aspect of understanding the organization of files in a Linux system. Here’s a comprehensive overview of the main directories and their purposes:

1. / (Root Directory):

  • The base of the file system hierarchy.
  • Contains all other directories and files.

2. /bin (Binaries):

  • Essential binary executables for system functioning.
  • Common commands like ls, cp, mv, mkdir, etc.

3. /boot (Boot Loader Files):

  • Files required for booting the system.
  • Kernel, boot loader configuration, and boot-related files.

4. /dev (Devices):

  • Device files representing physical and virtual devices.
  • Examples include /dev/sda (first hard disk), /dev/null (null device).

5. /etc (Configuration Files):

  • System-wide configuration files.
  • Settings for software, system services, and system administration.

6. /home (Home Directories):

  • User home directories.
  • Each user has a subdirectory here, containing their files.

7. /lib (Libraries):

  • Essential shared libraries for binaries in /bin and /sbin.
  • Kernel modules and hardware drivers.

8. /mnt (Mount Point):

  • Mount point for temporary mounting of filesystems.
  • External drives, network shares, or temporary mounts.

9. /opt (Optional Software):

  • Optional add-on software packages.
  • Often used for third-party software.

10. /proc (Process Information):

  • Virtual directory that provides information about processes.
  • Contains files and directories that represent running processes.

11. /root (Root Home Directory):

  • Home directory for the root user (superuser).

12. /run (Runtime):

  • Runtime data of running system since last boot.
  • Frequently changing data (process IDs, system state).

13. /sbin (System Binaries):

  • Essential system administration binaries.
  • Commands required for system repair, recovery, and maintenance.

14. /srv (Service Data):

  • Data used by services provided by the system.
  • Often used to serve data related to services like HTTP, FTP, etc.

15. /sys (System Information):

  • Virtual file system that provides information about the system and hardware.

16. /tmp (Temporary Files):

  • Temporary files accessible by users and processes.
  • Cleared on system reboot.

17. /usr (User Binaries and Libraries):

  • Secondary hierarchy containing user utilities, applications, and libraries.
  • Similar to the root hierarchy with its own /bin, /lib, /sbin, and /usr.

18. /var (Variable):

  • Variable files that are expected to change in size and content.
  • Log files, spool files, cache, etc.

Additional Notes:

  • Symbolic links (shortcuts) might exist for easier access to directories or files.
  • The directory structure forms a tree-like hierarchy starting from the root directory.

Understanding the Linux directory structure is fundamental for navigating and managing files and directories within a Linux-based system.