If you are a beginner and you want to know more about the directory structure, this guide is for you. We will explain the brief information about the standard Linux directory structure.
Standard Linux Directory Structure Explained
Linux is built on UNIX, so it has a filesystem hierarchy which is similar to UNIX. Let’s have a look at the Linux’s directory structure:
- General Files: Consisting of binary or ASCII data are called “general files”. Regular files, including documents, photos, audio and video files, etc., are included here.
- Directory Files: Since directories are used to store additional files and folders, they are also considered files in Linux.
- Device Files: In an operating system that resembles Windows, devices like CD-ROMs and hard drives are represented by drive letters such as F: G: H. However, in the Linux system, widgets are represented by files. The /dev directory contains them.
The Linux/Unix operating system stores files in a tree-like layout that starts with the root directory.
/ – The Root Directory
In Linux, the root is the top-level directory that stores all the directories such as documents, music, and downloads. The root home directory (/root) and the root directory (/) should be distinct.
/bin – Binaries
The /dev directory contains all the executable binary files that a system requires to run properly. Most of the apps in this system are in binary format and are available to all users of the Linux operating system.
/dev – Device Files
The /dev directory contains all the special files that represent the hardware devices like hard drives, network adapters, and printers. You can find the virtual files that represent the linked hardware parts like a mouse, keyboard, storage devices, etc., under the /dev directory.
/etc – Configuration Files
The /etc directory contains the system configuration files like system-wide config files, network settings, and application-specific config files. The system-wide configuration files are available in the /etc/directory.
/usr – User Binaries and Program Data
The /usr directory stores the user programs and related files of the system. Most system programs’ executable files, libraries, and source code are under “/usr”. Hence, most files that are included therein are read-only (for the typical user).
/home – User Personal Data
The /home directory contains the home directories for all the individual users. Each user on the system can keep their data distinct from other users’ data using home directories.
/lib – Shared Libraries
The /lib directory contains all the shared library files that are used by the system and other apps. It has the libraries for the essential binaries in the /bin and /sbin folders in the /lib directory. The /usr/lib folder contains the libraries that the binaries in the /usr/bin folder require.
/sbin – System Binaries
The /sbin directory has the system binaries that are used by the system administrator. It includes necessary binaries that are often made to be used by the root user to administer the system.
/tmp – Temporary Files
The /tmp directory stores all the temporary files that the applications and systems create. You can delete tmpwatch anytime your system is rebooted. Some Linux systems routinely destroy the old files, so keep everything crucial here.
/var – Variable Data Files
The /var directory stores all the variable data like email messages, log files, and other application data. System administrators can search here for data regarding the behavior of their systems because the files that are kept here are NOT automatically wiped out.
/boot – Boot Files
The /boot directory contains all the files that the system boot loader uses to start the Linux OS. Along with the kernel, it also saves the initial RAM filesystem or initramfs.
/proc – Process and Kernel Files
The /proc directory contains information on the currently running processes and the system hardware. At the startup, the system creates a temporary file system and removes it when a user turns it off.
/opt – Optional Software
The /opt directory stores optional add-on software that is not required by the system. For all users to be able to operate the software, it is customary to maintain the source code in opt and link the binary file in the /bin directory.
/root – The Home Directory of the Root
The /root is the home directory for the root users of your system. It is available at /root as opposed to /home/root. This is not the same as / or the system root directory.
/media – Mount Point for Removable Media
The /media mounts the removable media devices like USB drives and CDs. For instance, the system generates a directory in the /media directory when you put a CD into a Linux system.
/mnt – Mount Directory
The /mnt directory is used as a temporary mount point for file systems. It is similar to the /media directory, but the system administrators use mnt to mount the filesystems rather than automatically mounting the removable media explicitly.
/sys – System Information
The /sys directory stores all the information about the system hardware and device in Linux.
/srv – Service Data
The /srv directory stores all the important data for services that the system stores. For example, the files of your website must be inside the /srv directory if you use the Apache HTTP server for the website.
/run – Temporary File System
The /run directory has all the runtime data like system processes and service information. At the beginning of the boot process, the files in the /run directory must be deleted (or removed or reduced, as appropriate).
Conclusion
This guide shows a brief information on the standard Linux directory structure that you should know as a user. As mentioned earlier, the Linux directory structure resembles a tree, with the directories branching off the root. At the same time, the Linux file system hierarchy itself originates at the root.