Unlike the Windows system, Linux does have a lot of different directory structures which we will be discussing today. In Linux, all the directories retain from the root or base directory (/). Inside the base directory, if you use the ls command to list the file and dir you could also see some symlinks that point to other directories using ( → ). The symlinks also known for symbolic links is the type of file in Linux that points to another file or directory in the system. It is kind of similar to shortcuts in windows.

If you are new to Linux understanding directory structure is the initial phase. Without it, you might get headaches while managing the files and directories. So this article will help you cover up and understanding the directory structure of Linux OS. To demonstrate this article I have used Ubuntu 20.04 LTS system.

The directory structure of Linux

User Binaries (/bin)

This directory contains executable binaries of different command and system programs that are being used for single-user modes. For example ls, ping, cp, grep, etc.

Boot Loader (/boot)

All the boot loader files and their associated files are located in this directory. Such as kernels, initrd, grub, etc related files located here.

Device Files (/dev)

All the hardware-related files do contain inside this directory. This directory contains system all hardware devices related files which let the different programs interact with devices on the system.

Configuration Files (/etc)

This directory consists of all configuration files, shutdown as well ad startup shell scripts of the programs. Whenever you install the application on the system by default its configuration file will be created in this directory.

Home Directory (/home)

This is the default home directory of all the users that consist of their own respective environmental setup and personal files. A new directory under its username is created on this directory when we create a new user.

System Libraries (/lib)

The lib directory contains libraries need for binaries file located at /bin and /sbin to run different commands in the root file system.

Mount Directory (/mnt)

The mnt directory is used for temporary mounting of the filesystem.

Optional for add-on application (/opt)

Opt generally refers to optional which is the installation location for the third-party software. Different third-party software is located in this directory.

Process Info (/proc)

The proc directory contains information about the running process along with their PID or process id. A pseudo and virtual file system that holds text-based information about the system resource and process.

Root Home Directory (/root)

You shouldn’t mix the root directory (/) with /root both are completely different. ‘/root’ is the root user default home directory just like other user home directories.

Run-time Varibale (/run)

This directory contains system information since it was last booted that describes currently running daemons and logged-in users.

System Binaries (/sbin)

The sbin directory also contains executable binary files that are used for maintaining the system by the system administrator. System maintenance commands like fdisk, iptables, ifconfig, reboot, etc are executed from it.

Sysfs File System (/sys)

The pseudo file system that stores various information devices connected to the system and about various kernel subsystems especially in the latest Linux distro.

Temporary Files (/tmp)

The temporary filesystem in Linux is accessible by root as well as other users that tend to store temporary files and documents. Once the system is rebooted all the files inside the tmp directory will be deleted.

User Programs (/usr)

For second-level programs, this directory holds source code, documentation, executable binaries, libraries. It contains binary files for user programs as well as system binary files for system administrators.

Variable Files (/var)

The var is the short form for the variable that is used to store lock, mail, log, temp, and spool files. During the normal operation of the system, the content of the files inside this directory is expected to grow.

Conclusion

Understanding the Linux file system may lead to efficient workflow while managing software, logs files, documents, etc. I hope now you had a clear concept of the directory structure of Linux.

Directory structure of the Linux operating system explained

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn