This article provides an overview of the directory structure of the Linux file system, highlighting key files, their functions, and their locations.

In UNIX and its derivatives like Linux, the concept is that everything is treated as a file. If it’s not a file, then it’s likely a running process.

Linux files can be broadly categorized into three types:

General Files: These are regular files containing binary or ASCII data. They encompass various file formats, such as documents, images, audio, and video files.

Directory Files: In Linux, directories are considered files as well. They serve as containers for organizing and storing other files and folders.

Device Files: These special files act as interfaces to device drivers, enabling the utilization of hardware devices on the system. Examples include mice, keyboards, USB devices, and hard drives. Device files are typically located in the /dev directory.

Linux Directory Structure Diagram

A standard Linux distribution follows the directory structure as provided below with Diagram and explanation.

Each of the above directories (which is a file, in the first place) contains important information, required for booting to device drivers, configuration files, etc. Describing briefly the purpose of each directory, we are starting hierarchically.

/ Directory

The root directory is represented by a single forward slash (/) and serves as the highest-level directory in the Linux directory structure. It encompasses all other directories, subdirectories, and files present in your Linux system. It marks the starting point of the Linux directory hierarchy.

Please note that the root directory (/) should not be mistaken for the root home directory (/root).

/boot Directory

The boot directory holds significant importance within a Linux system. As the name suggests, it contains essential boot files for Linux, including the bootloader, the kernel, and related files. For instance, the file ‘vmlinuz’ represents the compressed image of the Linux kernel.

/etc Directory

The /etc directory serves as the centralized location for system configuration files in Linux. It houses configuration files for various services, scripts, and third-party applications that are installed on the system. Considered the nerve centre of the Linux system, the /etc directory plays a crucial role in managing and maintaining the configuration settings for different components of the operating system.

/home Directory

The /home directory is where a user’s personal folders and files are stored in Linux. On a graphical Linux system, this directory typically includes default folders such as Desktop, Documents, Downloads, Pictures, Videos, and Public, which provide organization for user files.

Moreover, the /home directory also houses personal configuration files that are prefixed with a dot (.), making them hidden files. These hidden files store user-specific settings for the login shell session, allowing users to customize their environment according to their preferences.

/root Directory

The /root directory serves as the home directory specifically designated for the root user in Linux. It is important to note that the /root directory is distinct from the root (/) directory, which is the top-level directory in the file system hierarchy.

The root user, often referred to as the superuser, administrative user, system administrator, or simply root, possesses full access to system commands and files in Linux. This privileged account holds the highest level of authority, allowing the root user to execute administrative tasks and make changes to the system configuration.

/opt Directory

The /opt directory is specifically designated for add-on packages and third-party software applications that are not included by default in the official repositories of the system.

When installing applications like Skype, Discord, Spotify, Java, and others, they are typically stored in the /opt directory. This directory provides a designated location for such software installations, keeping them separate from the system’s core files and allowing for easier management and organization of third-party applications.

/dev Directory

The /dev directory is home to device files or special files that represent various devices connected to the system, such as hard drives, keyboards, and mice. It’s important to note that these files are not regular files that users can directly read from or write to.

Device files in the /dev directory serve as abstractions of standard devices, enabling applications on the system to interact with them through input and output system calls. They provide a standardized interface for software to communicate with hardware devices, allowing for efficient and consistent device access across different applications and processes.

/var Directory

The /var directory stores system-generated variable files, which include log files, caches, and spool files just to mention a few.

/bin Directory

The /bin directory houses user binaries, executable programs, and common system commands that are utilized by all users on the system. It encompasses a range of essential commands such as ls, pwd, cat, mkdir, cd, mv, cp, du, df, tar, rpm, wc, history, and more. These commands play a fundamental role in everyday tasks and system operations for all users.

/sbin Directory

The /sbin directory houses executable files, utilities, and system commands that are specifically reserved for the root user or a user with root privileges. These commands are designed for administrative tasks and system management. Examples of such commands include halt, reboot, mkfs, fsck, fdisk, iptables, ifconfig, ip, swapon, and more. The commands found in the /sbin directory are crucial for system configuration, troubleshooting, and maintaining the overall system integrity, and they require elevated privileges for execution.

/usr Directory

The /usr directory holds significant importance within the Linux file system due to its vast collection of data. It encompasses system-wide read-only files that play a crucial role in the functioning of the system. This directory contains a wide range of data, including libraries, user binaries, their accompanying documentation, programs, and various system utilities. The /usr directory serves as a central location for shared resources, enabling multiple users to access and utilize these files and utilities across the system.

/proc Directory

The /proc directory is a unique and virtual filesystem in Linux. It serves as a pseudo filesystem that provides essential information about running processes and acts as the control and information center for the Linux kernel.

Unlike traditional directories, the /proc directory is not stored on a physical storage device. Instead, it is created dynamically in memory during system startup and is destroyed when the system is powered off or rebooted.

The /proc directory offers a structured interface that allows users and system utilities to access and retrieve real-time information about various processes, system configurations, hardware devices, and more. It provides a convenient way to interact with the kernel and obtain valuable insights into the system’s current state.

/mnt Directory

The /mnt directory, along with its subdirectories, serves as a designated location for temporary mount points in Linux. Its primary purpose is to facilitate the mounting of storage devices, including hard disk drives, USB drives, and CD-ROMs.

When a storage device needs to be accessed or its contents need to be made available to the system, it can be temporarily mounted under the /mnt directory or its subdirectories. By mounting a device, the file system of the device becomes accessible and integrated into the existing directory structure of the system, allowing users to interact with its files and data.

The /mnt directory provides a standardized and convenient location for temporary mounts, ensuring that the mounted devices are easily identifiable and accessible by users and system utilities.

/sys Directory

The /sys directory is a virtual file system that acts as an interface to the Linux kernel. It consists of a collection of virtual files that allow interaction with and access to various aspects of the kernel. These virtual files provide a means to retrieve information, configure system parameters, and monitor different components of the Linux kernel. The /sys directory serves as a valuable resource for managing and understanding the inner workings of the kernel and its associated subsystems.

/media Directory

The /media directory serves as the mount point for removable media, specifically designed to accommodate devices like USB drives in the Linux system. When a removable media device such as a USB drive is connected to the system, it is typically automatically mounted under the /media directory. This allows users to easily access and interact with the contents of the connected removable media through the designated mount point. The /media directory provides a convenient and organized location for managing and accessing data from various removable media devices.

/run Directory

The /run directory serves as a temporary filesystem in Linux, housing volatile runtime data that reflects the system’s state since it was last booted. It contains files and directories that hold information relevant to the current runtime session.

It’s important to note that the files under the /run directory are considered temporary and should be cleared at the beginning of the boot process. This ensures that any previous runtime data is removed, providing a clean and fresh start for the system.

The /run directory plays a crucial role in maintaining runtime information and facilitating inter-process communication during a system session. It helps in managing and coordinating various system components and their dynamic data while ensuring a clean slate for each boot cycle.

/tmp Directory

The /tmp directory serves as a storage location for temporary files in Linux. Many programs utilize this directory to create temporary files and lock files, as well as for temporary data storage during their execution.

It is important to exercise caution when dealing with files under the /tmp directory. Unless you have a clear understanding of their purpose and impact, it is advisable not to delete these files. Numerous critical files in the /tmp directory are actively utilized by running programs, and removing them indiscriminately may lead to system instability or even a system crash.

The /tmp directory plays a vital role in providing a space for temporary data exchange and storage among various programs. It is essential to exercise caution and refrain from deleting files unless you have explicit knowledge of their necessity and potential consequences.

/lib Directory

The /lib directory serves as a storage location for essential standard libraries that are required by user binaries located in the /bin directory. These libraries contain precompiled code that provides necessary functionality and support for various programs and applications.

When user binaries in the /bin directory are executed, they often rely on the standard libraries stored in the /lib directory to access common functions and routines. These libraries act as a foundation for the proper functioning of the user binaries, providing them with the necessary resources and functionalities.

The /lib directory is critical in ensuring that user binaries can access and utilize the standard libraries they depend on, contributing to the overall stability and functionality of the Linux system.

/lost+found Directory

The lost+found directory is installed during the installation of Linux, useful for recovering files that may be broken due to unexpected shut-down.

/srv Directory

The /srv directory, short for “service directory,” is a designated location for server-specific and service-related files in Linux. It serves as a centralized directory for storing data, configuration files, and other resources specific to various services running on the system.

The /srv directory provides a convenient and organized space for managing and accessing files related to different services, such as web servers, FTP servers, and other network services. It is typically used by system administrators and service providers to store data and configurations relevant to specific services.

By utilizing the /srv directory, administrators can keep service-related files separate from system-wide files, ensuring better organization and easier management of service-specific data and resources.

Exploring Important file, their location, and their Usability

Linux is a sophisticated operating system that requires an efficient and intricate approach to system startup, shutdown, maintenance, and rebooting, unlike Windows. It encompasses a well-defined configuration file, binaries, man pages, and info files for each process in Linux.

In addition to the major directories, here is a compilation of notable files and directories along with their purposes:

/boot/vmlinuz: This file contains the Linux Kernel.

/dev/hda: Device file for the first IDE HDD (Hard Disk Drive).

/dev/hdc: Device file for the IDE Cdrom.

/dev/sda: Device file for the first SATA Drive (Hard Disk Drive).

/dev/null: A pseudo-device used to discard unwanted output.

/etc/bashrc: Contains system-wide defaults, functions, and aliases for all system users.

/etc/crontab: A uniquely formatted system-wide file used to schedule or automate system tasks.

/etc/exports: Determines which file systems are exported to remote hosts and specifies options.

/etc/fstab: Special file containing information about available mount points and their options.

/etc/hosts: Config file mapping system hostnames to their corresponding IP addresses.

/etc/hosts.allow: Specifies hosts permitted to connect to the local system.

/etc/hosts.deny: Specifies hosts denied access and services on the local machine.

/etc/issue: Contains a pre-login message displayed to users.

/etc/modules: Lists kernel modules to be loaded at boot time.

/etc/motd: Contains the “message of the day” displayed to users upon login.

/etc/mtab: Read-only file listing currently mounted filesystems.

/etc/passwd: File containing system user information such as usernames, UIDs, GIDs, and login shells.

/etc/printcap: Contains printer information generated by /etc/cups/printers.conf.

/etc/profile: Contains Linux system-wide environment and startup scripts.

/etc/profile.d: Directory for application scripts executed after login.

/etc/rc.d: Contains information about run level-specific scripts.

/etc/rc.d/init.d: Directory for run level initialization scripts.

/etc/resolv.conf: DNS resolver file specifying hostname resolution using DNS.

/etc/security: Contains configuration files for various PAM (Pluggable Authentication Modules) modules.

/etc/skel: Directory containing user configuration files copied to new users’ home directories.

/etc/X11: Directory containing configuration files for the X Window System.

/usr/bin: Directory for normal user executable commands.

/usr/bin/X11: Directory containing binaries and nested directories for the X Window System.

/usr/include: Directory with header files for C compilers.

/usr/share: Shared directories for man files, info files, etc.

/usr/lib: Directory with object files and directories.

/usr/sbin: Directory for binaries with superuser privileges or system administration tools.

/proc/cpuinfo: File containing system information, including CPU model, cores, and clock speed.

/proc/interrupts: Information about currently utilized interrupts.

/proc/ioports: File listing Input/Output addresses used by devices on the server.

/proc/meminfo: File storing memory usage information, including swap details.

/proc/modules: File listing all modules being used by the kernel.

/proc/mounts: Detailed information about mounted file systems.

/proc/stat: File with detailed information about system and kernel activity.

/proc/swaps: File containing information about the swap file.

/proc/version: File with Linux version information.

/var/log/lastlog: Binary file containing information about the last successful user log

ins.

/var/log/messages: Log file capturing messages produced by the syslog daemon during boot.

/var/log/syslog: File containing non-critical system logs.

/var/log/wtmp: File listing user login time and duration on the system.

Please stay connected to Tecmint for Linux and FOSS-related news and posts. Stay healthy, and feel free to share your valuable comments in the comment section.

Comments to: Linux Directory Structure and Important Files Paths Explained

    Your email address will not be published. Required fields are marked *