The Wayback Machine - https://web.archive.org/web/20260323224444/https://www.geeksforgeeks.org/linux-unix/linux-directory-structure/

Linux Directory Structure

Last Updated : 9 Jan, 2026

In Linux, everything is treated as a file even if it is a normal file, a directory, or even a device such as a printer or keyboard. All the directories and files are stored under one root directory which is represented by a forward slash /.

  • The Linux directory layout follows the Filesystem Hierarchy Standard (FHS).
  • This standard defines how directories are organized and what types of files should be stored in each.
  • Since Linux is based on UNIX, it inherits many of UNIX’s filesystem conventions.
  • Similar directory structures are also found in other UNIX-like operating systems such as BSD and macOS.

Types of files in the Linux system

Linux categorizes files into different types based on their purpose, such as general data storage, system structure, or device representation.

types_of_files_in_linux
  1. General Files - It is also called ordinary files. It may be an image, video, program, or simple text file. These types of files can be in ASCII or Binary format. It is the most commonly used file in the Linux system.
  2. Directory Files - These types of files are a warehouse for other file types. It may be a directory file within a directory (subdirectory).
  3. Device Files - In a Windows-like operating system, devices like CD-ROM and hard drives are represented as drive letters like F: G: H, whereas in the Linux system, devices are represented as files. As for example, /dev/sda1, /dev/sda2, and so on.

We know that in a Windows-like operating system, files are stored in different folders on different data drives like C: D: E:, whereas in the Linux/Unix operating system, files are stored in a tree-like structure starting with the root directory, as shown in the diagram below. 

The Linux/Unix file system hierarchy base begins at the root and everything starts with the root directory. 

Top-level directories associated with the root directory

These top-level directories under the root (/) form the foundation of the Linux file system, each serving a specific role in organizing system files, user data, and configurations.

  • /bin - Contains essential binary or executable programs required for basic system operation.
  • /etc - Stores system-wide configuration files used to control system behavior.
  • /home - Contains user home directories and serves as the default working directory for users.
  • /opt - Holds optional or third-party software packages installed separately from the system.
  • /tmp - Provides temporary storage space for files, which is typically cleared on system reboot.
  • /usr - Contains user-related programs, utilities, and shared resources.
  • /var - Stores variable data such as log files that change frequently during system operation.

Some other directories in the Linux system

These directories support core functionality, hardware access, runtime processes, and system-level operations in a Linux environment.

  • /boot - Contains all boot-related files and directories, including kernel and boot loader configuration files.
  • /dev - Stores device files that represent hardware devices such as disks and partitions.
  • /lib - Contains shared libraries and kernel modules required for system programs to function.
  • /lost+found - Used to store recovered fragments of corrupted files after file system checks.
  • /media - Contains subdirectories where removable media devices like USB drives and CDs are mounted.
  • /mnt - Provides temporary mount points for manually mounting file systems.
  • /proc - A virtual file system that provides information about running processes and system status using process IDs (PIDs).
  • /run - Stores volatile runtime data such as process IDs and system information.
  • /sbin - Contains essential system administration binary executables.
  • /srv - Stores server-specific data related to services provided by the system.
  • /sys - A virtual file system used to interact with and manage hardware devices and kernel information.

Steps to Check Linux Directories from Root (/)

[Step 1]: Open the terminal:

Launch the terminal from the application menu or by using a keyboard shortcut.

[Step 2]: Switch to root user:

Execute the command sudo -s and enter the system password to gain root privileges.

[Step 3]: Move to the root directory:

Change the current working directory to the root (/) directory.

[Step 4]: List all directories in the root directory:

Display all available directories present in the base directory.

[Step 5]: Review the directory structure:

Observe the listed directories such as system, user, configuration, and virtual directories.

 Linux directories

Exploring directories and their usability

In the Linux system some well-defined configuration files, binaries, main pages information files are available for every process. 

1

Linux Kernel File:

  • /boot/vmlinux - The Linux kernel file.

Device Files:

  • /dev/hda - Device file for the first IDE HDD.
  • /dev/hdc - A pseudo-device that output garbage output is redirected to /dev/null.

System Configuration Files

System configuration files are essential files stored in the /etc directory that define system behavior, user access, boot settings, network rules, and service management in Linux.

  1. /etc/bashrc - Contains system-wide default settings and aliases for the Bash shell.
  2. /etc/crontab - Used to schedule commands or scripts to run automatically at predefined time intervals.
  3. /etc/exports - Stores information about file systems that are shared over the network.
  4. /etc/fstab - Contains details about disk drives and their mount points.
  5. /etc/group - Stores information about system groups and group memberships.
  6. /etc/grub.conf - Configuration file for the GRUB boot loader.
  7. /etc/init.d - Contains service startup and shutdown scripts.
  8. /etc/lilo.conf - Configuration file for the LILO boot loader.
  9. /etc/hosts - Maps IP addresses to corresponding hostnames.
  10. /etc/hosts.allow - Specifies which hosts are allowed to access services on the local machine.
  11. /etc/hosts.deny - Lists hosts that are denied access to services on the local machine.
  12. /etc/inittab - Defines the INIT process behavior and system run levels.
  13. /etc/issue - Displays the pre-login message shown before user login.
  14. /etc/modules.conf - Contains configuration settings for system kernel modules.
  15. /etc/motd - Stores the “message of the day” displayed after user login.
  16. /etc/mtab - Provides information about currently mounted file systems.
  17. /etc/passwd - Contains user account information such as usernames and user IDs (passwords are stored in the shadow file).
  18. /etc/printcap - Stores configuration details related to printers.
  19. /etc/profile - Defines system-wide environment settings for the Bash shell.
  20. /etc/profile.d - Contains additional scripts executed automatically after user login.
  21. /etc/rc.d - Helps manage system initialization scripts and avoids script duplication.
  22. /etc/rc.d/init.d - Contains scripts used to start and stop services during run levels.
  23. /etc/resolv.conf - Stores DNS configuration used by the system.
  24. /etc/security - Contains security-related configuration files, including login access controls.
  25. /etc/skel - Holds default files copied to a new user’s home directory.
  26. /etc/termcap - ASCII file defining behavior and capabilities of different terminal types.
  27. /etc/X11 - Directory containing configuration files for the X Window System.

These directories under /usr contain essential user-space programs, libraries, headers, and shared data used by both regular users and administrators.

  • /usr/bin - Contains most of the user-level executable programs and commands.
  • /usr/bin/X11 - Acts as a symbolic link to /usr/bin and is related to X Window System executables.
  • /usr/include - Stores standard header files used by C and other programming languages.
  • /usr/share - Contains architecture-independent, shareable data such as documentation and text files.
  • /usr/lib - Holds object files and shared libraries required by programs in /usr/bin.
  • /usr/sbin - Contains administrative commands used by the system administrator (superuser).

These /proc files provide real-time system and process information generated dynamically by the Linux kernel.

  • /proc/cpuinfo - Provides detailed information about the CPU, such as processor type, model, and speed.
  • /proc/filesystems - Displays the file systems supported and currently available in the system.
  • /proc/interrupts - Shows information about the number of interrupts handled by each IRQ.
  • /proc/ioports - Contains details of input and output addresses used by hardware devices.
  • /proc/meminfo - Reports detailed information about system memory usage.
  • /proc/modules - Lists the kernel modules that are currently loaded in the system.
  • /proc/mounts - Displays information about all mounted file systems.
  • /proc/stat - Provides detailed statistics about system activity and performance.
  • /proc/swaps - Contains information about swap space and swap files in use.

Version Information File

Quickly view the current Linux OS version using this file.

  • /version - It displays the Linux version information.

Log Files

These files record crucial system events, logins, and activity history for monitoring and troubleshooting.

  • /var/log/lastlog - Stores information about the last login of each user.
  • /var/log/messages - Contains global system messages and general system activity logs.
  • /var/log/wtmp - Maintains a history of user login and logout sessions.
Comment
Article Tags:

Explore