Simplified: Linux Directory Structure [Part 2]
Tags: linux, devops, sysadmin
Published: 2023-07-05 18:30:13

Introduction
This is a part 2 of  [Linux Directory Structure part 1](https://dev.to/titusnjuguna/simplified-linux-directory-structure-part-1-2j5e). If your are learning Linux kindly check out the first post in order to have a better understanding 

#/media

![media Directory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lb6fgek43iy6km0wohg.png)

The /media directory plays a specific role in automatically mounting external storage devices when they are connected and accessed. Unlike other entries on this list, /media is not rooted in the 1970s because it is a result of the more recent development of on-the-fly insertion and detection of storage devices (such as USB drives, external hard disks, SD cards, external SSDs, etc.) while a computer is running.

#/mnt

In contrast, the /mnt directory persists as a remnant from earlier times, primarily intended for manually mounting storage devices or partitions. However, its relevance and usage have greatly diminished in modern times.

#/opt

![opt directory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ellhnll35y3iqv15i428.png)
The /opt directory is frequently used to store manually compiled software, which means it is built from source code instead of being installed from distribution repositories. Within this directory, applications are usually stored in /opt/bin, while libraries are placed in /opt/lib.
As a slight deviation, another location where applications and libraries are occasionally installed is /usr/local. When software is installed in this directory, corresponding /usr/local/bin and /usr/local/lib directories are created. The decision of which software goes to each location depends on how the developers have configured the files governing the compilation and installation process.

#/proc

![Proc Direcotry](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vft6k36y06b411f5ojyh.png)

Similar to /dev, /proc is a virtual directory that contains computer-related information, such as details about your CPU and the kernel running on your Linux system. Like /dev, the files and directories in /proc are dynamically generated either during system startup or as your system operates and undergoes changes.

#/run

/run is another new directory. System processes use it to store temporary data for their own nefarious reasons. This is another one of those DO NOT TOUCH folders.

#/sbin

/sbin, resembling /bin, houses applications that are specifically intended for use by the superuser (hence the "s" in the directory name). These applications can be accessed using the sudo command, which grants temporary superuser privileges on many distributions. /sbin usually comprises tools capable of installing, deleting, and formatting various components. It is crucial to exercise caution while using these instructions since some of them can have severe consequences if utilized incorrectly.

#/srv

The /srv directory is designated for storing server-related data. For instance, if you operate a web server on your Linux machine, the HTML files for your websites would be placed in /srv/http (or /srv/www). Similarly, if you run an FTP server, the files would be stored in /srv/ftp.

#/sys

![sys directory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eqbl5ty10b1j0bw192rb.png)

Similar to /proc and /dev, /sys is another virtual directory that contains information from devices connected to your computer. In some cases, it is also possible to manipulate those devices. For example, adjusting the brightness of a laptop screen can be achieved by modifying the value stored in the /sys/devices/pci0000:00/0000:00:02.0/drm/card1/card1-eDP-1/intel_backlight/brightness file (note that the file path may vary on different machines). However, performing such actions requires superuser privileges. This is because, like many other virtual directories, tampering with the contents and files in /sys can be risky and may lead to system issues. It is crucial to exercise caution and avoid making any changes unless you are confident in your understanding of the consequences.

#/bin

The /bin directory is where binary files, including various applications and programs, are stored. This directory houses fundamental tools such as the mentioned ls program, which is used for listing files. It also includes essential utilities for creating and deleting files and directories, as well as moving them. While there are additional bin directories scattered throughout the file system tree, we will discuss those in a moment.

#/var

The naming of the /var directory originally implied that its contents were variable, as they were expected to change frequently. However, in modern times, this name can be misleading because there are other directories, including virtual directories mentioned earlier, that also contain frequently changing data.

Nevertheless, /var encompasses various items, such as logs found in the sub-directories of /var/log. Logs are files that record system events, including kernel failures logged in files within /var/log, or firewall attempts to breach your computer from external sources, which are also logged here. Additionally, /var holds spools for tasks. These tasks can include print jobs sent to a shared printer, causing a delay if another user is printing a lengthy document, or mail waiting to be delivered to system users.

It's worth noting that your system may have additional directories not mentioned above. For instance, in the provided screenshot, there is a /snap directory, which is specific to Ubuntu systems. Ubuntu has recently introduced snap packages as a method of software distribution, and the /snap directory contains the files and software installed from snap packages.