The Linux operating system we use has a myriad of bells and whistles underneath it to function as we see it. Although there are many flavours of Linux Distribution, the fundamental concepts are all the same. The basic underlying thing they rely on is the partitions. In Linux, there are more than 10 partitions, each performing a particular task. Each is suited for specific purposes. Missing even a single partition can be fatal unless the kernel has been modified in some way.

Now, let's dive into all the directories available in Linux and learn in-depth about them.

user@app-server:/$ ls /
bin   dev  home        initrd.img.old  lib32  libx32      media  opt   root  sbin  sys  usr  vmlinuz
boot  etc  initrd.img  lib             lib64  lost+found  mnt    proc  run   srv   tmp  var  vmlinuz.old

Contents of / directory

The Directories

/

First of all the / directory, this is the directory that holds the entire file system hierarchy. All the files, directories, binaries, etc, exist in the / directory. The directories except / are all known as sub-directories.

/boot

Secondly the /boot directory, these store the static bootloader file and kernel executable images. It contains files like vmlinux, initrd, bootloader config files, and is crucial for starting up the operating system.

/bin

Third, we have the /bin directory, this directory contains binary files required for the functioning of the Operating System. The binaries available in /bin are available to all users of the operating system.

/dev

Next, we have /dev, this contains special device files that represent the physical media devices. The Hard/Solid Disk that is used for the OS will be in /dev/sda, /dev/tty contains terminals, /dev/null is a black hole; anything you put in there gets lost. If you ever need to generate random numbers, then /dev/random is the best place to do so.

It basically provides an interface for user-space applications to interact with the devices connected to the hardware or software devices (like disks getting loaded when installing apps via .dmg files).

/etc

/etc is the central location for configuration files that are used throughout the whole system. The file that is used the most is probably /etc/passwd and /etc/fstab. It's essential for configuring the various components and services in the system.

/home

/home directory holds personal directories and files for regular users, every user in the system can have a sub-directory, there can also be users that don't have sub-directories. The home directory can be used for storing personal data, config files (dot files), etc. Only the owner of the home directory and the root user itself can access the /home/owner directories unless permissions are given explicitly.

/lib

/lib directory contains shared libraries required by binaries present in the /bin directory. All the essential libraries required for core system utilities are present in the /lib directory.

/lib32 & /lib64

/lib32 and /lib64 are present in 32-bit and 64 systems, respectively. lib32 can also be found on 64-bit systems, whereas lib64 is only found in 64-bit systems.

/media

/media directory is a mount point for removable media devices like pen drives, memory cards, CD drives, blu-ray players, etc. When any of these devices are connected, they are typically mounted in /media directory.

/opt

/opt is reserved for optional or third-party software packages and add-on applications. Software packages like browsers, office suites and development tools. It should be used to keep core system directories and additional software separate.

/proc

This virtual filesystem provides information regarding data structures and processes running in the system. Various files and subdirectories represent system resources and kernel parameters in the /proc directory. It can be used for monitoring and adjusting system settings during runtime. Learn more about /proc it here, where I've covered its functionality in-depth.

/proc In Linux Systems - Yarsa DevBlog
Discover how sysadmins can optimize Linux systems using the powerful /proc directory, from process management to performance monitoring and troubleshooting.

/root

The /root directory is the home directory of the superuser account. It is typically used by the sys admin for configurations. It acts like /home directory and has similar characteristics, except that other users in the system cannot access it by default; only the root account can.

/run

The /run directory is a directory for holding data used at runtime for various processes and services in a temporary manner. The process IDs, lock files and other data can be seen in this directory. It usually gets cleared when the system is rebooted, or a specific service is restarted.

/sbin

The /sbin directory has binary executables for sys admin tasks. The programs like ifconfig, fsck, init, etc are available in this directory and are typically only accessible by the root user.

/srv

The /srv directory is used for data related to services provided by the system, like websites, FTP servers, etc. It can be useful for separating service-specific data from the core system directory.

/sys

The /sys directory is a virtual filesystem that provides information about system hardware, connected devices, kernel features, etc. It allows us to view and adjust kernel parameters and settings related to hardware devices. Also used for interacting with the kernel and system components at a low level.

/tmp

The /tmp directory is a directory that can be accessed by all users in the system. It should be used temporarily for storing data; on every reboot, the /tmp directory is cleared of data. It can be used as a shared space for file storage if files need to be shared in the same system between different users.

/usr

The /usr directory is a very important directory because it contains user related programs, libraries, documentation and other data. The subdirectories, like /usr/bin for binaries, /usr/lib for libraries and /usr/share for data sharing, exist inside the /usr directory.

/var

The /var directory has variable data, like log files, spool files, mail queues, and database files. Data that is frequently written to or modified is typically found in the /var directory.

Conclusion

Each of the above-mentioned directories has a specific purpose and adheres to the Filesystem Hierarchy Standard to ensure a consistent organization of files and directories across Linux/Unix distributions. According to the distribution, some may have extra directories or may be missing a directory or two.

Resources

Filesystem Hierarchy Standard
This standard consists of a set of requirements and guidelines for file and directory placement under UNIX-like operating systems. The guidelines are intended to support interoperability of applications, system administration tools, development tools, and scripts as well as greater uniformity of documentation for these systems.
Thank you for reading, please comment below if you have any queries. I periodically update my articles to ensure legibility.