Linux Directory Structure Explained – The Complete Guide

By | September 1, 2023

Linux-based operating systems adhere to the Linux Filesystem Hierarchy Standard (FHS), a well-defined directory structure maintained by the Linux Foundation.

This standardization brings several benefits, including ease of use for both users and software developers by providing a consistent location for installed binaries, system files, and system information.

While transitioning from Windows to Linux, users may encounter challenges due to different directory structure. Linux lacks the familiar C and D drives found in Windows, and its directory conventions can be really confusing.

This article aims to clarify the Linux directory structure, hierarchies, and the appropriate directories for storing different file types.

In this article, we will delve into the intricacies of the Linux directory structure, examining each directory's role and purpose.

Filesystem Hierarchy Standard (FHS)

The Filesystem Hierarchy Standard (FHS) outlines conventions for organizing a UNIX system's layout. While widely adopted in Linux distributions, it is also utilized by other UNIX variants. Maintained by the Linux Foundation, the latest version, 3.0, was released on June 3, 2015.

Linux operates based on the UNIX operating system structure, which is shared by operating systems such as BSD and macOS. Familiarity with this directory structure allows for improved navigation on Linux systems. Now, let's delve into the diverse Linux directory structures without delay.

Directory Structure

Now lets take a look at each of the directories one by one and see what each one does.

  • /
  • /bin
  • /boot
  • /dev
  • /etc
  • /home
  • /lib
  • /media
  • /mnt
  • /opt
  • /run
  • /sbin
  • /srv
  • /tmp
  • /proc
  • /sys
  • /var
  • /lost+found
  • /root
  • /usr

/ (root)

In Linux, the root directory ("/") acts as the entry point for the file system hierarchy, covering all directories, files, and sub-directories. It is denoted by a forward slash ("/").

The root directory includes various directories like /bin (containing binaries), /etc (containing system configuration files), /home (containing user home directories), /var (containing variable data), and a few more.

Essentially, the root directory forms the fundamental framework upon which the entire Linux directory structure is built.

You can switch to the root directory with the cd command

$ cd /

The contents of the root directory at the first level look somewhat like this on a modern Ubuntu desktop installation:

$ ls -l
total 112
lrwxrwxrwx   1 root root     7 Sep 10  2021 bin -> usr/bin
drwxr-xr-x   3 root root  4096 Jun 17 11:01 boot
drwxr-xr-x   2 root root  4096 Feb 15  2017 cdrom
drwxr-xr-x  20 root root  4900 Jun 21 11:01 dev
drwxr-xr-x 198 root root 16384 Jun 18 12:08 etc
drwxr-xr-x   4 root root  4096 Jun  2 11:26 home
lrwxrwxrwx   1 root root    32 Jan  8  2020 initrd.img -> boot/initrd.img-5.0.0-38-generic
lrwxrwxrwx   1 root root    32 Jan  8  2020 initrd.img.old -> boot/initrd.img-5.0.0-37-generic
lrwxrwxrwx   1 root root     7 Sep 10  2021 lib -> usr/lib
lrwxrwxrwx   1 root root     9 Sep 10  2021 lib32 -> usr/lib32
lrwxrwxrwx   1 root root     9 Sep 10  2021 lib64 -> usr/lib64
lrwxrwxrwx   1 root root    10 Sep 10  2021 libx32 -> usr/libx32
drwx------   2 root root 16384 Feb 15  2017 lost+found
drwxr-xr-x   5 root root  4096 Jun  2 11:46 media
drwxr-xr-x   2 root root  4096 Oct 13  2016 mnt
drwxr-xr-x   7 root root  4096 Aug 17  2020 opt
dr-xr-xr-x 549 root root     0 Jun  6 12:55 proc
drwx------  21 root root  4096 Jun  4 15:08 root
drwxr-xr-x  38 root root  1120 Jun 23 10:08 run
lrwxrwxrwx   1 root root     8 Sep 10  2021 sbin -> usr/sbin
drwxr-xr-x  22 root root  4096 Jun 10 16:30 snap
drwxr-xr-x   3 root root  4096 Sep 17  2020 srv
dr-xr-xr-x  13 root root     0 Jun  6 12:55 sys
drwxrwxrwt  28 root root 32768 Jun 23 16:26 tmp
drwxr-xr-x  22 root root  4096 May 25  2022 usr
drwxr-xr-x  15 root root  4096 Jul 11  2017 var
lrwxrwxrwx   1 root root    29 Jan  8  2020 vmlinuz -> boot/vmlinuz-5.0.0-38-generic
lrwxrwxrwx   1 root root    29 Jan  8  2020 vmlinuz.old -> boot/vmlinuz-5.0.0-37-generic
$

Note that the top-level layout of directories in the root (/) may vary slightly across different distros, but will be largely similar.

On a Fedora desktop the contents look like this:

[silver@fedora ~]$ cd /
[silver@fedora /]$ ls -l
total 20
dr-xr-xr-x.   1 root root    0 Aug  9  2022 afs
lrwxrwxrwx.   1 root root    7 Aug  9  2022 bin -> usr/bin
dr-xr-xr-x.   7 root root 4096 Jan  9 17:04 boot
drwxr-xr-x.  20 root root 3920 Jun 23 16:48 dev
drwxr-xr-x.   1 root root 4730 Jan  9 20:30 etc
drwxr-xr-x.   1 root root   12 Aug  9  2022 home
lrwxrwxrwx.   1 root root    7 Aug  9  2022 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Aug  9  2022 lib64 -> usr/lib64
drwx------.   1 root root    0 May  5  2022 lost+found
drwxr-xr-x.   1 root root    0 Aug  9  2022 media
drwxr-xr-x.   1 root root    0 Aug  9  2022 mnt
drwxr-xr-x.   1 root root   50 Jan  9 17:46 opt
dr-xr-xr-x. 274 root root    0 Jun 23 16:48 proc
dr-xr-x---.   1 root root  216 Aug  9  2022 root
drwxr-xr-x.  47 root root 1320 Jun 23 16:48 run
lrwxrwxrwx.   1 root root    8 Aug  9  2022 sbin -> usr/sbin
drwxr-xr-x.   1 root root    0 Aug  9  2022 srv
dr-xr-xr-x.  13 root root    0 Jun 23 16:48 sys
drwxrwxrwt.  18 root root  460 Jun 23 16:49 tmp
drwxr-xr-x.   1 root root  100 Jan  9 16:55 usr
drwxr-xr-x.   1 root root  194 Jan  9 17:39 var
[silver@fedora /]$

/bin - Program binaries

The "/bin" directory in Linux serves as a location for storing executable binaries, which are essential programs needed for the basic functioning of the system. Denoted by "/bin", this directory provides access to executable files for all users on the system.

Within this directory, users can find a range of command-line utilities and core system binaries that offer indispensable functionalities, such as file management, text processing, and system administration.

One of the biggest advantages of having these binaries in the "/bin" directory is their universal accessibility. They can be executed from any location in the system without specifying the complete file path.

The directories that are present in the $PATH environment are used to find programs and command executable files when invoked by user.

$ echo "$PATH"
/home/silver/.local/bin:/home/silver/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
$

This convenience is possible due to the inclusion of the "/bin" directory in the system's "PATH" environment variable, which specifies directories to search for executable binaries.

While certain Linux distributions may have additional directories like "/usr/bin" for user-installed binaries, the critical system binaries are usually located in "/bin".

We'll shortly be discussing the key differences between "/bin" and "/usr/bin" towards the end of the article.

/boot - Boot files, kernel images

In Linux, the "/boot" directory plays an important role by storing crucial files associated with the system's boot process. It contains components like the kernel, initial RAM disk (initrd), and bootloader configuration files. All the mentioned files are used for the booting process.

During system startup, the bootloader, such as GRUB, retrieves the necessary information from the "/boot" directory to initiate the boot process.

The kernel is represented by a file named "vmlinuz", or a similar variant which serves as the core component of the operating system. The initrd consists of an initial file system and drivers necessary for the boot process.

Storing these critical files in the "/boot" directory ensures their accessibility and facilitates efficient loading during system startup. Maintaining the "/boot" directory in an organized and well-managed manner is crucial for ensuring the stability and proper functioning of the Linux system.

Following are few files that can be found inside /boot directory:

  • /boot/grub: It contains the GRUB configuration files, including boot-up images and sounds.
  • /boot/grub/device.map: Maps devices in /dev to those used by grub.
  • /boot/grub/grub.conf, /boot/grub/menu.lst: It contains the grub configuration file.
  • /boot/grub/messages: It contains a grub boot-up welcome message.
  • /boot/grub/splash.xpm.gz: It contains a grub boot-up background image.
[silver@fedora /]$ ls /boot
config-5.17.5-300.fc36.x86_64  grub2                                                    loader                             System.map-5.17.5-300.fc36.x86_64                  vmlinuz-6.0.17-200.fc36.x86_64
config-6.0.17-200.fc36.x86_64  initramfs-0-rescue-ccdaee37fe8742d79ba63db58721dfbc.img  lost+found                         System.map-6.0.17-200.fc36.x86_64
efi                            initramfs-5.17.5-300.fc36.x86_64.img                     symvers-5.17.5-300.fc36.x86_64.gz  vmlinuz-0-rescue-ccdaee37fe8742d79ba63db58721dfbc
extlinux                       initramfs-6.0.17-200.fc36.x86_64.img                     symvers-6.0.17-200.fc36.x86_64.gz  vmlinuz-5.17.5-300.fc36.x86_64
[silver@fedora /]$

/dev - Devices

The "/dev" directory in Linux holds significant importance as it represents the devices present in the system. It contains special files that act as interfaces to a wide range of hardware devices, including disks, terminals, input/output devices, etc.

These files enable user programs and system utilities to establish communication and interact with these devices effectively.

Within the "/dev" directory, we can identify entries in accordance to their devices, such as "/dev/sda" for a disk, "/dev/ttyUSB0" for a USB serial port, and "/dev/input/event0" for an input device.

These files adhere to standardized conventions, providing a uniform approach to access and manipulate the connected hardware devices.

For example, the following few files can be found inside /dev:

  • /dev/null: it can be sent to destroy any file or string.
  • /dev/zero: it contains an infinite sequence of 0.
  • /dev/random: it contains an infinite sequence of random values.

/etc

The Linux "/etc" is a directory that stores a collection of system configuration files. Named after "et cetera," it contains a wide range of files necessary for configuring the system, services, and applications.

Contained within the "/etc" directory are configuration files that govern the behavior and settings of the Linux system. These files provide instructions and parameters for various aspects, such as network configuration, user authentication, software packages, system services, socket information and more.

Noteworthy files found in "/etc" include "passwd" for user account information, "hosts" for hostname-to-IP mapping, "resolv.conf" for DNS configuration, and "fstab" for defining file systems and their mount points.

Additionally, many applications and services installed on the Linux system store their configuration files in the "/etc" directory. These files define behavior, preferences, and application-specific options.

Examples include "apache2.conf" for the Apache web server, "sshd_config" for the OpenSSH server, and "mysql.cnf" for the MySQL database server.

Here's an example of few subdirectories that can be found inside /etc:

  • /etc/bashrc: It contains system-wide functions and aliases among other files that are used by all the system users.
  • /etc/crontab: This is a system-wide file that is uniquely formatted to schedule or automate system tasks on a Linux system.
  • /etc/exports: A file that determines which file systems are exported to remote hosts and specifies options.
  • /etc/hosts: This is a configuration file that maps system hostnames to their corresponding IP addresses.

To summarize, the "/etc" directory in Linux acts as a central hub for system configuration files, providing flexibility and control over various aspects of the operating system, services, and applications.

Note: This directory cannot contain binary executable files according to FHS.

/home - User files

The "/home" directory in Linux acts as the default location for user home directories. It plays an important role in effectively organizing and managing user-specific data, configurations, and personal files.

Within the "/home" directory, each Linux user is assigned a separate home directory. For example, if a user named "tom" is created, his home directory would be located at "/home/tom". This directory functions as an exclusive space where users can securely store their personal files, documents, settings, and preferences.

Also, all the user-specific configuration files for each application can be found in /home/username/.conf. For example, for tom, it would be - /home/tom/.conf.

User-specific configuration files, such as ".bashrc" for customizing the shell environment or ".profile" for defining user-specific environment variables, are typically stored within their respective home directories.

The "/home" directory offers several advantages. Firstly, it provides a centralized space for users to access and manage their files, ensuring convenience and efficient organization of data.

Secondly, it enhances security by segregating user-specific files from system files; minimizing the risk of unintended modifications or deletions of crucial files. In short, it provides a more organized space for the users.

To summarize, the "/home" directory in Linux serves as the default location for user home directories, offering a private and secure space for users to store personal files and configurations. It streamlines file organization, reinforces security measures, and facilitates user administration.

/lib - Library files

The "/lib" directory in Linux is a significant location that stores shared library files necessary for the functioning of the operating system and various other applications.

Shared libraries, also referred to as dynamic link libraries, consist of reusable code and functions that multiple programs can utilize simultaneously, reducing redundancy and optimizing system resources. These libraries enable efficient program execution and facilitate code sharing among different applications.

Also, these libraries offer a wide range of functionalities, including memory management, input/output operations, networking protocols, graphics rendering, etc.

The "/lib" directory contains both system libraries, which are essential for the stability and core functionality of the operating system, and third-party libraries, which are additional libraries installed by users or applications to provide specific features or meet dependencies.

A lot of times, there are different 32-bit and 64-bit libraries with the same name. To avoid any confusion, these binaries are kept in two separate directories accordingly named /lib32 and /lib64.

While the "/lib" directory predominantly comprises shared libraries, it may also incorporate other files, such as firmware or kernel modules, depending on the specific Linux distribution and system configuration.

For example, following are few subdirectories that can be found inside /lib:

  • /lib/modules: The '/lib/modules' contains kernel modules and has a directory for each installed kernel.
  • /lib32 and /lib64: Contain libraries specifically for 32-bit and 64-bit build process respectively

To summarize, the "/lib" directory in Linux serves as a crucial repository for vital shared libraries that provide essential functionalities to the operating system and applications. It facilitates code sharing, enhances efficiency, and ensures seamless integration between programs.

Familiarity with the "/lib" directory is indispensable for system administrators and developers to uphold a stable and functional Linux environment.

/media -

In Linux, the "/media" directory is used to automatically mounts removable media devices like USB drives, optical discs, or external hard drives upon access after connection. It acts as a unified location where users can easily access and manage the files and folders stored on these devices.

The /media directory a separate sub-directory for each user name (account) on the system and each user sub-directory has a separate sub-directory for each mounted device, enabling all the users to easily navigate and interact with the contents.

To summarize, the "/media" directory simplifies the process of working with removable media in Linux systems, enhancing the overall usability and convenience for users.

It should be noted that the /media directory is used by the system to automatically mount the disk devices when accessed from file managers like Dolphin or Nautilus. It is not supposed to be used to manual mounting. If a user wants to manually mount a drive using the mount command, then the mount point directory should be somewhere inside /mnt directory.

/mnt

In Linux, system administrators can manually mount temporary or external file systems in the "/mnt" directory. This directory acts as a versatile mount point for a variety of devices and network shares.

Unlike the "/media" directory, which is automatically used for mounting removable media, the "/mnt" directory offers administrators the flexibility to mount specific drives or file systems manually as and when required.

By providing a unique location, it simplifies the access and management of manually mounted or temporary file systems, enabling administrators to efficiently organize and utilize additional storage or network resources.

/opt

In Linux, the "/opt" directory serves as a location for the installation of third-party software packages that are not included in the default system installation or not available via approved software repositories. It ensures a well-structured and organized file system hierarchy by offering a separate space for these applications.

By isolating third-party software from the core system files and libraries, system administrators can maintain them independently and without interference.

The primary advantage of the "/opt" directory lies in its ability to accommodate commercial or proprietary software that necessitates separate installation from the operating system. This directory provides a specific location where such applications can be installed, updated, and managed without impacting the vital components of the system.

To summarize, this directory structure greatly simplifies the process of locating and handling optional software packages on a Linux system.

Here is how the contents look on a typical ubuntu system.

$ ls -l /opt
total 20
drwxr-xr-x 3 root root 4096 Aug 15  2020 extras.ubuntu.com
drwxr-xr-x 3 root root 4096 Aug 29  2017 google
drwxr-xr-x 2 root root 4096 Apr  6  2019 kingsoft
drwxr-xr-x 2 root root 4096 Dec  7  2018 skypeforlinux
drwxr-xr-x 5 root root 4096 Sep 12  2017 yEd
$

The directory google contains google chrome browser for instance, and skypeforlinux contains the skype application.

/run

In Linux, the "/run" directory acts as a transient file system where runtime data and information pertaining to active processes are stored. This directory is generated during system boot and utilized by both the operating system and applications to store critical runtime files, including process identifiers (PIDs), socket files, and system-specific data.

The "/run" directory also facilitates the management of dynamic data that requires access by currently running processes. It is customary for the contents of the "/run" directory to be cleared upon system restart, guaranteeing a clean slate for runtime data in each session.

Furthermore, the volatile nature of the "/run" directory ensures the continual refreshing of runtime information during system operations.
Hence, the data that is shown is real-time data.

/sbin

The "/sbin" directory in Linux stores essential system binaries and executables that are primarily utilized by system administrators to manage and maintain the system.

The "/sbin" directory contains a diverse range of commands and utilities specifically designed for system-level operations. These executables are executed with elevated privileges, such as root or superuser, as they handle tasks requiring advanced permissions and system control.

These binaries cover different functionalities, including system startup and shutdown, network configuration, disk management, device administration, and security operations.

Common examples of commands found in "/sbin" are "shutdown" for initiating system shutdown, "ifconfig" for configuring network interfaces, "fdisk" for disk partitioning, and "iptables" for managing firewall rules.

By segregating system binaries into the "/sbin" directory, critical administrative tools remain easily accessible to priviledged users while reducing the risk of accidental misuse by regular users.

Having a comprehensive understanding of the purpose and contents of the "/sbin" directory is essential for system administrators and advanced users involved in system management tasks. This directory serves as a centralized location for crucial system-level binaries, ensuring efficient administration and maintenance of the Linux system.

/srv

In Linux, the "/srv" directory is a location for storing data associated with system services. It acts as a designated directory for storing site-specific data, including websites, FTP servers, and repositories.

What sets the "/srv" directory apart from directories like "/var" or "/home" is its explicit focus on service-related data. By utilizing the "/srv" directory, system administrators can maintain a clear separation between service data and system data, streamlining the management and organization process to increase the observability.

To summarize, this directory serves as a location for storing service data, ensuring consistency and facilitating the effortless deployment and maintenance of services within a Linux system.

This directory is not used very frequently on desktop setups.

/tmp

The "/tmp" directory in Linux acts as a temporary storage location for files and directories created by various processes and applications. It is a widely adopted practice for programs to utilize the "/tmp" directory for storing data that is needed temporarily or for inter-process communication.

The primary objective of the "/tmp" directory is to provide a dedicated space where applications can conveniently create and access temporary files without cluttering other directories within the system.

Files stored in "/tmp" are typically transient in nature and are automatically removed upon system reboot.

The "/tmp" directory is accessible to all users and processes on the system, granting them the capability to generate and retrieve temporary files as necessary.

However, it is essential to recognize that the files inside "/tmp" are not protected and can be accessed by other regular users by default. Consequently, it is crucial to enforce proper permissions and implement security measures when working with sensitive data.

Moreover, it is worth noting that certain Linux distributions mount "/tmp" as a separate file system to optimize performance. This approach enables the utilization of specific file system optimizations tailored for temporary data storage.

In summary, the "/tmp" directory in Linux is a temporary storage location for files and directories generated by processes and applications.

/proc

The "/proc" directory in Linux serves as a unique directory that acts as an interface to the kernel and its processes. Rather than containing physical files, it presents a virtual view of the system's active processes and their associated information.

These directories contain files and subdirectories that expose a variety of details pertaining to the respective processes, including process IDs, memory usage, CPU information, network statistics, and more. By accessing these virtual files, system administrators and monitoring tools can retrieve real-time data about the system's status.

Here are some common /proc "virtual files" to gather system information:

  • /proc/cpuinfo : Information about cpu cores
  • /proc/uptime : System uptime information
  • /proc/version : Kernel version and build information
  • /proc/diskstats : Disk statistics
  • /proc/partitions : Disk partition details
  • /proc/meminfo : Memory / RAM information

Furthermore, the "/proc" directory provides a means to modify specific system parameters and configurations by writing to designated files.

In conclusion, the "/proc" directory in Linux serves as a powerful interface for accessing real-time information about processes and system parameters. It plays a vital role for system administrators, developers, and monitoring utilities, offering essential capabilities for managing and understanding the system's behavior.

/sys (distro specific)

The "/sys" directory in Linux, although its specifics can vary between different distributions, holds significant importance as it grants access to the kernel's device and driver information. It operates as a virtual file system, presenting a structured and hierarchical layout composed of directories, subdirectories, and files.

These components represent the various hardware elements, buses, and drivers present in the system, offering comprehensive details about their status, settings, and associated attributes.

By utilizing the "/sys" directory, system administrators and advanced users gain the ability to directly interact with the system's hardware and drivers. They can query and modify device settings, monitor device status, and diagnose hardware-related issues. Moreover, the directory facilitates the troubleshooting and configuration of various system components.

It is essential to recognize that the specific structure and content of the "/sys" directory can differ across Linux distributions. While the core functionality remains consistent, it is crucial to refer to distribution-specific documentation or resources to determine the details and file locations.

To summarize, the "/sys" directory in Linux serves as an invaluable resource for accessing and managing device and driver information. Its availability and utility render it an indispensable tool for system administration, hardware configuration, and troubleshooting purposes.

/var

The "/var" directory in Linux is an essential component of the filesystem hierarchy. It serves as a location for storing variable data generated by various processes during the system's runtime. The "/var" directory contains files and directories that hold dynamic data that can change frequently, such as log files, spool files, cached data, and temporary files.

/var/log : One of the key subdirectories within "/var" is "/var/log," which is dedicated to storing system log files. These log files record important information about the system's activities, events, and error messages. They are crucial for system monitoring, troubleshooting, and security analysis.

/var/cache - Another subdirectory is "/var/cache," which holds cached data. Caching allows frequently accessed data to be stored temporarily, improving system performance by reducing the need to retrieve the data from slower storage devices.

/var/spool : The "/var/spool" directory, on the other hand, is used for storing print and mail spool files. These files represent pending tasks or jobs waiting to be processed, such as print jobs in the printing queue or emails in the mail spool.

By separating variable data into the "/var" directory, the Linux system maintains a clean and organized filesystem hierarchy. This separation ensures that the core system files and directories remain separate from the frequently changing data.

It allows for efficient management and maintenance of system logs, cached data, and spool files. Additionally, the "/var" directory is often located on a separate partition or file system, which prevents it from affecting the stability of the overall system, in case it becomes full or experiences issues.

Following subdirectories are found inside /var:

  • /var/log: It contains system log files generated by OS and other applications.
  • /var/lib: It contains database and packages files.
  • /var/mail: It contains emails.
  • /var/tmp: It contains temporary files needed for reboot.

In summary, the "/var" directory plays a crucial role in Linux for storing variable data generated by various processes. It encompasses subdirectories like "/var/log," "/var/cache," and "/var/spool" that hold system logs, cached data, and spool files respectively.

By providing a dedicated location for such data, the "/var" directory helps maintain an organized filesystem hierarchy and ensures efficient system monitoring, troubleshooting, and performance optimization.

/lost+found (ext4 feature)

The "/lost+found" directory is a special feature specific to the ext4 file system in Linux. It serves as a repository for orphaned files and directories that are recovered during file system checks.

When the ext4 file system undergoes a filesystem check (fsck) and encounters inconsistencies or errors, it may come across files and directories that are not linked to any parent directory. These orphaned files are then moved to the "/lost+found" directory to preserve them and prevent data loss.

The "/lost+found" directory is typically located at the root of the file system, and each mounted ext4 partition has its own instance of this directory. During a filesystem check, if any orphaned files are discovered, they are assigned a numerical name and placed within the "/lost+found" directory.

It's important to note that the original names and directory structure of these files may not be preserved in this process.

Once the file system check is complete, system administrators can examine the contents of the "/lost+found" directory and attempt to recover or restore the orphaned files. However, it can be challenging to identify and restore files since the original names and directories are lost. The recovered files may need to be inspected and manually organized or deleted if they are deemed unnecessary.

The presence of the "/lost+found" directory in ext4 file systems helps maintain the integrity of the file system by preserving orphaned files and preventing data loss. It serves as a safety net for files that would otherwise be lost during filesystem checks.

While it is not a directory that users interact with regularly, it plays a vital role in ensuring the reliability and recoverability of ext4 file systems.

/root (root user home)

The "/root" directory in Linux serves as the designated home directory for the root user, who is also referred to as the superuser or administrator. The root user possesses the highest level of privileges in the system, granting unrestricted access to all files, directories, and system resources.

In contrast to regular users who have their home directories located under "/home," the root user's home directory is specifically located at "/root." This directory functions as a centralized location for storing configuration files, scripts, and other user-specific data that are specific to the root user.

By navigating to the "/root" directory, the root user can access and modify system-wide configurations, carry out administrative tasks, and execute privileged commands. It is crucial to exercise caution when operating within the "/root" directory, as any alterations made can have a substantial impact on the system.

Access to the "/root" directory is restricted solely to the root user, ensuring that only the administrator can access and modify its contents. This segregation of the root user's home directory contributes to maintaining system security by isolating critical administrative files and minimizing the potential for accidental modifications or unauthorized access.

/usr

The "/usr" directory in Linux is an important directory that holds user-related files and programs. It is composed of several subdirectories, each serving a specific purpose. Here are some notable subdirectories within the "/usr" directory:

  • /usr/bin: This directory contains executable files (binaries) that are accessible to all users. It includes essential commands and programs used for day-to-day operations.
  • /usr/sbin: Similar to "/usr/bin," this directory stores system administration binaries. However, the executables in "/usr/sbin" are primarily intended for system administrators and require elevated privileges.
  • /usr/lib: This directory houses libraries, which are collections of code utilized by other programs. It includes shared libraries and module files used by various applications.
  • /usr/include: Here, you can find header files necessary for software development. Header files define functions, structures, and constants used during the compilation of programs.
  • /usr/share: This directory stores architecture-independent data, such as documentation, examples, and data files, that can be shared across different systems.
  • /usr/local: Reserved for locally installed software or additional programs not included in the core system distribution, this subdirectory allows system administrators to install software tailored to their specific needs.
  • /usr/games: It contains games and entertainment programs for users to enjoy.
  • /usr/libexec: This directory stores system-specific executables designed for use by other programs rather than being executed directly by users.

The "/usr" directory and its subdirectories have a crucial role in organizing user-related files, programs, and resources on a Linux system. They contribute to a well-structured and efficient file system hierarchy, making it easier to access and manage user-related software and data.

/bin vs. /usr/bin

The key distinction between the "/bin" and "/usr/bin" directories in Linux pertains to their purpose and accessibility.

The "/bin" directory holds vital executable files (binaries) that are indispensable for the fundamental operation of the system. These binaries encompass essential commands used by both regular users and the system itself. The "/bin" directory is accessible to all users and is an integral part of the core system distribution.

In contrast, the "/usr/bin" directory serves as a storage location for executable files that are not essential for the basic system functionality. It encompasses supplementary commands and programs, primarily intended for regular users rather than critical system operations.

Similar to "/bin," the "/usr/bin" directory is accessible to all users. However, it is separate from the core system distribution, allowing for customization and the installation of additional software.

Conclusion

Directories play a critical role in organizing and managing files, programs, and system resources within the Linux operating system. Adhering to the FHS enables Linux systems to maintain a standardized directory structure, fostering portability, interoperability, and ease of administration.

Key directories like "/bin," "/sbin," "/usr," "/var," and "/etc" are defined by the FHS, each serving specific purposes. For example, essential system binaries reside in "/bin" and "/sbin," while user-related files and programs are stored in "/usr." The "/var" directory houses variable data, such as logs and temporary files, while configuration files are found in "/etc."

These directories, along with their subdirectories, establish a logical organization of files, simplifying resource location and access for system administrators and users. The FHS also emphasizes modularity and separation of concerns, ensuring that critical system files remain isolated from user-specific data.

In conclusion, the Linux directory structure and the FHS establish a standardized, systematic and organized approach to file and resource management.

Links and Resources

Filesystem Hierarchy Standard
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

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