Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Types of Files in Linux System
2.
Linux Directory Structure
2.1.
1. / — The Root Home Directory 
2.2.
2. /boot Directory Static Boot Files
2.3.
3. /etc - Files Directory Configuration 
2.4.
4. /home - Home Folders Directory
2.5.
5. /root Directory
2.6.
6. /opt - Optional Software Packages Directory
2.7.
 7. /dev - Device Files Directory
2.8.
8. /var - Variable Data Files Directory
2.9.
9. /bin - Essential User Binaries Directory
2.10.
10. /sbin - System Administration Binaries Directory 
2.11.
11. /usr - User Binaries & Read-Only Data and program data Directory
2.12.
12. /media - Mount point for Removable Media Directory 
2.13.
13. /mnt - Temporary Mount Points Directory
2.14.
14. /proc - Kernel & Process Files Directory 
2.15.
15. /cdrom - Historical Mount Point for CD-ROMs
2.16.
16. /sys Directory
2.17.
17. /run - Application State Files Directory
2.18.
18. /tmp - Temporary Files Directory
2.19.
19. /lib - Essential Shared Libraries Directory
2.20.
20. /lost+found Directory 
2.21.
21. /srv - Service Data Directory
2.22.
22. /SELinux - SELinux Virtual File System
3.
Frequently Asked Questions 
3.1.
What is the directory structure in Linux?
3.2.
In Linux, how can I discover a directory?
3.3.
In Linux, how can I access the root directory?
3.4.
What is the Linux directory change procedure?
4.
Conclusion
Last Updated: Jul 12, 2024
Easy

Linux Directory Structure

Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM

The foundation of Linux is an open-source operating system that resembles Unix. Linus Torvalds initially published the Linux kernel on September 17, 1991.

There is a Filesystem Hierarchy Standard that the Linux Foundation maintains. UNIX system layout conventions are described in this reference. It describes how Linux distributions' folders are organized, and they are usability. There are several directories in every Linux distribution.

Types of Files in Linux System

The directories contain mainly three types of files:

  1. General files: The Linux operating system uses this file the most frequently. These are standard files. These files might be in binary or ASCII form. These are files like images, documents, audio, videos, etc.
  2. Directory files: Files in directories serve as storage for different file kinds and directories.
  3. Device files: In Linux, /dev/device id files serve as a representation for USB and other hardware parts. These files serve as an interface for the device drivers that make the system's hardware devices usable.

Linux Directory Structure

Directories and externally inserted hardware devices are all treated as files in the Linux/Unix operating system.

The Linux directory structure is organized like a tree, with the root (/) directory acting as the tree's main trunk, from which all other directories branch out. 

The directory structure in Linux will be examined in this blog.

Linux directories

These are the standard top-level directories associated with the root directory:

DirectoryDescription
/binUser binaries or executable programs.
/etcSystem configuration files.
/homeUser home directories - default current directory.
/optOptional and third-party applications or software.
/tmpTemporary files.
/usrUser applications related files.
/varVariable or log files.

Some other directories in the Linux system:

Certainly! Here is the expanded table including the additional directories:

DirectoryDescription
/rootRoot home directory.
/bootBoot loader files and folders such as conf, grub, etc.
/devLocation of device files.
/libKernel modules and shared system library.
/lost+foundRecovers corrupted and broken files.
/mediaSubdirectories where removable media devices are inserted.
/mntTemporary mount directory.
/procVirtual and pseudo-file system having information about process information.
/runStores volatile runtime data having a temporary file system.
/sbinSystem binary executable programs.
/srvServer-specific and server-related data.
/sysVirtual filesystem.
Linux directory tree structure

1. / — The Root Home Directory 

The forward slash (/) designates the root directory. In Linux, it keeps track of every directory. Every user in Linux has a unique home folder, and the root user is no different. The address of the root's residence is /root. The root user's home directory is located in the /root directory. Because the root directory is the parent of all other directories, every file's absolute path must travel through it.

 / — The Root Home Directory

2. /boot Directory Static Boot Files

The kernel and boot image files may be found in the Linux directory "/boot." The files required for the system to boot are located in the /boot directoryA Linux system needs this directory more than any other. As the name suggests, the boot directory houses the kernel, related files, and other crucial boot files that the boot loader needs. Here, the kernel is stored together with the initial RAM file system. The Linux kernel's compressed image can be found in files like "vmlinuz."

/boot Directory Static Boot Files 1
/boot Directory Static Boot Files 2

3. /etc - Files Directory Configuration 

The main configuration files for the system are located in the /etc Linux directory and may typically be modified manually with a text editor. Administrators and services like networking files and password files are the primary users of it. For all of the installed services, scripts, and third-party programs, the /etc/ directory houses system-wide configuration files. This directory is regarded as the backbone of the Linux system.

/etc - Files Directory Configuration

4. /home - Home Folders Directory

User data and configuration files relevant to each user are stored in folders located in the home directory. It's common practice to build a user's home directory when a user is created on a Linux system. Inside every user's directory, it has user-specific settings. Only the user's home folder is accessible to each user as a write location; super permission must be obtained to change any other system files. Individual users' folders and files are located in the /home directory. A dot appears before the /home directory (.).

/home - Home Folders Directory

5. /root Directory

The root user's home directory, or simply the root user's home directory, is located in the /root Linux directory. The root account is the system administrator, superuser, administrative user, or root user. It has complete access to Linux system files and commands.

6. /opt - Optional Software Packages Directory

Installing and storing third-party program files that are not accessible via the distribution repository takes place in the /opt Linux directory. The standard procedure is to save the program source code in /opt, after which it must link the binary file in the /bin Linux directory so that all the users may use it. The compatibility of some programs is improved as a result.

/opt - Optional Software Packages Directory

 7. /dev - Device Files Directory

Special virtual files that reflect the system's hardware-linked components are found in the /dev Linux directory. These aren't the classic documents that users may read and write on. System applications communicate with these standard device abstractions via input and output system calls.

 /dev - Device Files Directory

8. /var - Variable Data Files Directory

Applications store runtime data in the /var directory, including system logging, caches, user tracking, and other files that system programs generate and maintain. Variable stands for Var. System administrators can get information on their system's behavior in this location since the data kept there is not automatically wiped up. Sysadmins can gather and examine system logs as needed because the data in /var isn't immediately deleted.

/var - Variable Data Files Directory

9. /bin - Essential User Binaries Directory

The executable files for many common shell commands may be found directly in the directory '/bin.' Some examples of these include ls, cat, pwd, cd, mv, mkdir, wc, cp, df, du tar, rpm, and history. Most of the apps in this system are in binary format and available to all users of the Linux operating system.

/bin - Essential User Binaries Directory

10. /sbin - System Administration Binaries Directory 

The root user can only utilize the executable files, tools, and system commands found in the /sbin directory for system management. It includes binaries that can only be executed by a root, a sudo user, or a super user is the only distinction it creates from the /bin directory.

 /sbin - System Administration Binaries Directory

11. /usr - User Binaries & Read-Only Data and program data Directory

Most applications, system utilities, libraries, and data are under the /usr Linux directory. Users' files and apps are contained there. Sub-directories like /usr/share, /usr/local, /usr/bin, /usr/lib, and /usr/sbin are also present in the /usr directory. Due to the vast quantity of data, it contains, the /usr Linux directory is among the most significant Linux directory. System-wide read-only files can be found in the directory. 

 /usr - User Binaries & Read-Only Data and program data Directory

12. /media - Mount point for Removable Media Directory 

A subfolder inside the /media Linux directory is automatically generated for any connected removable media, such as a USB drive, SD card, or DVD. The removable media's content is accessible from this directory.

Generally, the system starts doing this automatically as you connect the device and deletes the associated subfolder when the device is removed. 

 /media - Mount point for Removable Media Directory

13. /mnt - Temporary Mount Points Directory

In contrast to /media directory, which mounts portable media automatically, mnt manually mounts filesystems. Storage devices are mounted momentarily using the /mnt Linux directory. Some Linux variants employ /mnt as a long-term storage option.

 /mnt - Temporary Mount Points Directory

14. /proc - Kernel & Process Files Directory 

Linux's "/proc" directory is a virtual or pseudo file system containing details on the kernel's settings and presently active processes. It is regarded as the Linux kernel's command and information hub. System data, including the processor and memory utilization, is found in the /proc Linux directory. Several utilities access the information included in the proc directory to learn about the system during runtime. When your Linux computer starts up, data is loaded into it and cleared out when you shut it down. 

 /proc - Kernel & Process Files Directory

15. /cdrom - Historical Mount Point for CD-ROMs

Despite not adhering to the Filesystem Hierarchy Standard, Ubuntu includes the /cdrom Linux directory. It serves as a temporary storage area for CD-ROMs introduced into the system. However, the /media directory is the preferred option for temporary media.

16. /sys Directory

Access to the Linux kernel is provided through a group of virtual files in the virtual file system known as /sys. A Linux directory includes details of the system's drivers and components. Though formatted differently, it is similar to /proc. For data collection, sysadmins alternately use /proc and /sys.

/sys Directory

17. /run - Application State Files Directory

The /run Linux directory provides programs with a common location to store temporary files by logging the system's volatile runtime information from boot time, including details about the active daemons, logged-in users, and more. 

/run - Application State Files Directory

18. /tmp - Temporary Files Directory

Temporary files are kept in this Linux directory by applications. The information in the /tmp directory is removed when your system restarts, no matter how momentary. Do not remove anything inside the /tmp directory, as some Linux systems erase outdated data automatically. Many of the files in this location are essential to the operation of active applications, and deleting them might result in a system crash.

/tmp - Temporary Files Directory

19. /lib - Essential Shared Libraries Directory

A library is a group of pre-compiled programs that binaries can utilize. All libraries required by the binaries( /bin and /sbin Linux directory) are located in the /lib Linux directory. They are found under the path /usr/lib. 

/lib - Essential Shared Libraries Directory

20. /lost+found Directory 

When Linux is installed, the lost+found directory is also installed. It helps restore files that an unplanned shutdown could have damaged.

21. /srv - Service Data Directory

"srv" refers to the service Linux directory in the /srv directory. It includes service-related and server-specific files. The files for your website would probably be kept in a directory inside the /srv directory if you were serving it using the Apache HTTP server.

22. /SELinux - SELinux Virtual File System

The /SELinux Linux directory has individual files that SELinux utilizes specifically if your Linux system utilizes SELinux for security. Ubuntu doesn't host SELinux. Thus the existence of this subdirectory there comes as a bug.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Frequently Asked Questions 

What is the directory structure in Linux?

The directory structure in Linux is a hierarchical filesystem starting from the root directory (/). It includes standard top-level directories like /bin, /etc, /home, /var, /usr, and others, each serving specific system and user-related functions.

In Linux, how can I discover a directory?

Open the terminal and type sudo -s followed by the system password to provide root privileges before checking the Linux directories.

In Linux, how can I access the root directory?

In Linux, you can access the root directory by using the cd / command in the terminal. For administrative tasks, use sudo to gain necessary permissions.

What is the Linux directory change procedure?

Using "cd" or "cd~," you may go to your home directory.

Conclusion

In this blog, we have discussed Linux Directory Structure. Understanding the Linux directory structure is fundamental for efficient navigation and management of the system. With its hierarchical organization and standard top-level directories, users can easily locate and access essential files and configuration settings, facilitating smooth operation and administration of Linux-based systems. 

If you think this blog has helped you enhance your knowledge of the above question, and if you want to learn more, check out our articles. Visit our website to read more such blogs. 

  1. Linux Kernel
  2. Linux Operating System
  3. Touch command in linux

 

But suppose you have just started your learning process and are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problemsinterview experiences, and interview bundles for placement preparations. Enroll in our courses and refer to the mock test and problems available; look at the Problem Sheets interview experiences, and interview bundle for placement preparations. You can also book an interview session with us.  

However, you may consider our paid courses to give your career an edge over others!

Live masterclass