Linux file hierarchy

Updated: 06/30/2020 by Computer Hope
Linux hierarchical file system structure

A Linux operating system has a hierarchical file structure, with the necessary directories for storing system, user, application, kernel, library, and temp files. The standard Linux commands are included in the file hierarchy, as well. Together, the directories, commands, and various types of files allow the Linux operating system to function properly.

Below is how the Linux file hierarchy is organized, including where the main Linux commands are located, and what files each directory stores. Click the blue triangle next to a directory name to expand and view additional details, including the types of files, commands, and sub-directories associated with that directory.

Linux file hierarchy

Note

The hierarchical file structure below is the minimum file system defined by the FHS (Filesystem Hierarchy Standard). Your Linux file system may have additional commands, files, and directories compared to what is shown below, especially if you have installed other packages and programs. Additionally, some Linux variants may diverge from the standard file system and look different than the structure below.

  • / (root directory)
    • /bin   (essential binaries)
    • /boot   (static files of the boot loader)
      • boot
      • grub
      • initrd
      • kernel
      • module.info
      • system.map
      • vmlinuz
    • /dev   (location of device/special files)
      • Contains device files created during installation.
    • /etc   (host-specific system configuration)
      • /opt   (configuration files for optional application software)
        • Contents vary depending on installed software.
      • csh.login
      • exports
      • fstab
      • ftpusers
      • gateways
      • gettydefs
      • group
      • host.conf
      • hosts
      • hosts.allow
      • hosts.deny
      • hosts.equiv
      • hosts.lpd
      • inetd.conf
      • inittab
      • issue
      • ls.co.conf
      • motd
      • mtab
      • mtools
      • networks
      • passwd
      • printcap
      • profile
      • protocols
      • resolv.conf
      • rpc
      • securetty
      • services
      • shells
      • syslog.conf
    • /home   (user home directories)
      • Initially empty, until a non-root user is created.
    • /lib   (library/kernel modules)
      • Contains libraries required by binaries in /bin and /sbin.
    • /mnt   (mount points for temporary file systems)
      • Initially empty in some distributions. Removable disks may be mounted here automatically when inserted.
    • /opt   (optional application file systems)
      • Contents vary depending on installed software.
    • /root   (home directory for the root user)
      • Initial contents may vary by distribution.
    • /sbin   (system binaries)
    • /tmp   (temporary files deleted when system boots)
      • Initially empty when system is booted.
    • /usr   (read-only and shareable data)
      • /bin   (contains most user commands)
      • /include   (C standard library header files)
      • /lib   (obj, bin, lib files for packages/programs)
        • If the system has an MTA (mail transfer agent) installed, a binary or symlink named sendmail must exist in this directory.
      • /local   (host-specific software and local data)
        • /bin
        • /games
        • /include
        • /lib
        • /man
        • /sbin
        • /share
        • /src
      • /sbin   (non-essential system binaries)
      • /share   (static data shareable across all architectures)
        • /man   (manual pages for general commands)
          • /man1   (manual pages for user programs)
          • /man2   (manual pages for system calls)
          • /man3   (manual pages for library functions)
          • /man4   (manual pages for special files)
          • /man5   (manual pages for file formats)
          • /man6   (manual pages for games, etc.)
          • /man7   (miscellaneous manual pages)
          • /man8   (manual pages for root commands)
    • /var   (files expected to grow, such as system logs)
      • /cache   (application cache data)
      • /lib   (variable state info that remains after reboot)
      • /lock   (lock files for shared resources)
      • /log   (log directory and files)
        • lastlog
        • messages
        • wtmp
      • /opt   (variable data of installed packages)
      • /run   (information of system since it was booted up)
      • /spool   (data waiting for processing)
        • /lpd
        • /mqueue
        • /news
        • /rwho
        • /uucp
      • /tmp   (temporary application files, not deleted on boot)
      • /yp   (files for NIS (Network Information Service))