Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Input Output Redirection in Linux
Next article icon

Linux Directory Structure

Last Updated : 07 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In Linux, everything is treated as a file even if it is a normal file, a directory, or even a device such as a printer or keyboard. All the directories and files are stored under one root directory which is represented by a forward slash /.

The Linux directory layout follows the Filesystem Hierarchy Standard (FHS). This standard defines how directories are organized and what types of files should be stored in each. Since Linux is based on UNIX, it inherits many of its filesystem conventions. Similar directory structures can also be found in other UNIX-like operating systems such as BSD and macOS. Understanding the Linux directory structure is essential for efficient system administration, file management, and problem-solving.

Types of files in the Linux system

Linux categorizes files into different types based on their purpose, such as general data storage, system structure, or device representation.

  1. General Files - It is also called ordinary files. It may be an image, video, program, or simple text file. These types of files can be in ASCII or Binary format. It is the most commonly used file in the Linux system.
  2. Directory Files - These types of files are a warehouse for other file types. It may be a directory file within a directory (subdirectory).
  3. Device Files - In a Windows-like operating system, devices like CD-ROM and hard drives are represented as drive letters like F: G: H, whereas in the Linux system, devices are represented as files. As for example, /dev/sda1, /dev/sda2, and so on.

We know that in a Windows-like operating system, files are stored in different folders on different data drives like C: D: E:, whereas in the Linux/Unix operating system, files are stored in a tree-like structure starting with the root directory, as shown in the diagram below. 

data storage in Linux/Unix operating systems

The Linux/Unix file system hierarchy base begins at the root and everything starts with the root directory. 

Also Read: Linux File Hierarchy Structure

Top-level directories associated with the root directory

These top-level directories under the root (/) form the foundation of the Linux file system, each serving a specific role in organizing system files, user data, and configurations.

DirectoriesDescription
 /bin binary or executable programs.
/etcsystem configuration files.
/homehome directory. It is the default current directory.
/optoptional or third-party software.
/tmptemporary space, typically cleared on reboot.
/usr User related programs.
/var log files.

Some other directories in the Linux system

These directories support core functionality, hardware access, runtime processes, and system-level operations in a Linux environment.

Directories Description
/boot

It contains all the boot-related information files and folders such as conf, grub, etc.

/dev

It is the location of the device files such as dev/sda1, dev/sda2, etc.

/lib

It contains kernel modules and a shared library.

/lost+found

It is used to find recovered bits of corrupted files.

/media

It contains subdirectories where removal media devices are inserted.

/mnt

It contains temporary mount directories for mounting the file system.

/proc

It is a virtual and pseudo-file system to contains info about the running processes with a specific process ID or PID.

/run

It stores volatile runtime data.

/sbin

binary executable programs for an administrator.

/srv 

It contains server-specific and server-related files.

/sys

It is a virtual file system for modern Linux distributions to store and allows modification of the devices connected to the system.

Exploring directories and their usability

We know that Linux is a very complex system that requires an efficient way to start, stop, maintain and reboot a system, unlike Windows operating system. In the Linux system some well-defined configuration files, binaries, main pages information files are available for every process. 

Linux Kernel File:

  • /boot/vmlinux - The Linux kernel file.

Device Files:

  • /dev/hda - Device file for the first IDE HDD.
  • /dev/hdc - A pseudo-device that output garbage output is redirected to /dev/null.

System Configuration Files

A collection of essential configuration files in the /etc directory that define system behavior, user access, boot settings, network rules, and service management in Linux.

Configuration FilesDescription
/etc/bashrcIt is used by bash shell that contains system defaults and aliases.
/etc/crontabA shell script to run specified commands on a predefined time interval.
/etc/exports It contains information on the file system available on the network.
/etc/fstabInformation of the Disk Drive and their mount point.
/etc/group It is a text file to define Information of Security Group.
/etc/grub.confIt is the grub bootloader configuration file.
/etc/init.d Service startup Script.
/etc/lilo.conf  It contains lilo bootloader configuration file.
/etc/hostsInformation of IP and corresponding hostnames
/etc/hosts.allowIt contains a list of hosts allowed accessing services on the local machine.
/etc/host.deny List of hosts denied accessing services on the local machine.
/etc/inittab INIT process and their interaction at the various run levels.
/etc/issueAllows editing the pre-login message.
/etc/modules.confIt contains the configuration files for the system modules.
/etc/motd It contains the message of the day.
/etc/mtab Currently mounted blocks information.
/etc/passwd  It contains username, password of the system, users in a shadow file.
/etc/printcap  It contains printer Information.
/etc/profile Bash shell defaults.
/etc/profile.dIt contains other scripts like application scripts, executed after login.
/etc/rc.d It avoids script duplication.
/etc/rc.d/init.d Run Level Initialisation Script.
/etc/resolv.confDNS being used by System.
/etc/security It contains the name of terminals where root login is possible.
/etc/skelScript that initiates new user home directory.
/etc/termcapAn ASCII file that defines the behavior of different types of the terminal.
/etc/X11Directory tree contains all the conf files for the X-window System.

User Related Files

These directories under /usr contain essential user-space programs, libraries, headers, and shared data used by both regular users and administrators.

User Related FilesDescriptions
/usr/bin It contains most of the executable files.
/usr/bin/X11 Symbolic link of /usr/bin.
/usr/include It contains standard files used by C program.
/usr/shareIt contains architecture independent shareable text files.
/usr/lib It contains object files and libraries.
/usr/sbinIt contains commands for Super User, for System Administration.

Virtual and Pseudo Process Related Files

These /proc files provide real-time system and process information generated dynamically by the Linux kernel.

Virtual and Pseudo Process Related FilesDescriptions
/proc/cpuinfoCPU Information
/proc/filesystemsIt keeps useful info about the processes that are currently running.
/proc/interrupts it keeps the information about the number of interrupts per IRQ.
/proc/ioportsContains all the Input and Output addresses used by devices on the server
/proc/meminfoIt reports the memory usage information.
/proc/modulesCurrently using kernel module.
/proc/mountMounted File-system Information.
/proc/statIt displays the detailed statistics of the current system.
/proc/swaps It contains swap file information.

Version Information File

Quickly view the current Linux OS version using this file.

  • /version - It displays the Linux version information.

Log Files

These files record crucial system events, logins, and activity history for monitoring and troubleshooting.

Log FilesDescriptions
/var/log/lastlog It stores user's last login info.
/var/log/messages It has all the global system messages
/var/log/wtmpIt keeps a history of login and logout information.

To check the Linux directories, open the terminal and execute sudo -s followed by system password to give root privilege. Then after changing the current home directory to the root directory and check the list of all available directories in the base directory as shown below. 

 Linux directories
 Linux directories

Conclusion

If we understand the Linux directory's structure correctly, it would be so easy to effectively navigate and manage our filesystem, locate important configuration files, and access system information. One must know that the directory structure and specific file mentioned in this article are based on standard Linux conventions. We must consider that the different Linux distributions may have variations in the directory structure and specific file locations, but overall concept and organization remain similar.


Next Article
Input Output Redirection in Linux

V

vikashgautam11
Improve
Article Tags :
  • Linux-Unix

Similar Reads

    Introduction to Linux Shell and Shell Scripting
    If we are using any major operating system, we are indirectly interacting with the shell. While running Ubuntu, Linux Mint, or any other Linux distribution, we are interacting with the shell by using the terminal. In this article we will discuss Linux shells and shell scripting so before understandi
    8 min read

    Introduction to Shell Scripting

    How to Create a Shell Script in linux
    Shell is an interface of the operating system. It accepts commands from users and interprets them to the operating system. If you want to run a bunch of commands together, you can do so by creating a shell script. Shell scripts are very useful if you need to do a task routinely, like taking a backup
    7 min read
    Different Shells in Linux
    SHELL is a program which provides the interface between the user and an operating system. When the user logs in OS starts a shell for user. Kernel controls all essential computer operations, and provides the restriction to hardware access, coordinates all executing utilities, and manages Resources b
    5 min read

    Basic Shell Commands in Linux

    Basic Shell Commands in Linux: Complete List
    Anyone using Linux should become an expert in the essential shell commands, as they form the backbone of working with the Linux terminal. These commands enable you to navigate the system, manage files, handle processes, and configure settings effectively.The Linux shell serves as an interface for us
    5 min read
    Linux Directory Structure
    In Linux, everything is treated as a file even if it is a normal file, a directory, or even a device such as a printer or keyboard. All the directories and files are stored under one root directory which is represented by a forward slash /. The Linux directory layout follows the Filesystem Hierarchy
    6 min read
    Input Output Redirection in Linux
    In Linux, whenever an individual runs a command, it can take input, give output, or do both. Redirection helps us redirect these input and output functionalities to the files or folders we want, and we can use special commands or characters to do so. For example, if we run the "date" command, it giv
    4 min read

    Variables and Data Types

    Shell Scripting - Shell Variables
    A shell variable is a character string in a shell that stores some value. It could be an integer, filename, string, or some shell command itself. Basically, it is a pointer to the actual data stored in memory. We have a few rules that have to be followed while writing variables in the script (which
    6 min read
    Shell Scripting - Rules for Naming Variable Name
    Variables are quite important in any script or program, so we need to understand what is the convention to name these variables. There are certain rules and standards to keep in mind while giving names to the variables in Shell scripting. In this article, we will discuss and list down all the rules
    4 min read
    String Manipulation in Shell Scripting
    String Manipulation is defined as performing several operations on a string resulting change in its contents. In Shell Scripting, this can be done in two ways: pure bash string manipulation, and string manipulation via external commands. Basics of pure bash string manipulation: 1. Assigning content
    4 min read
    Array Basics in Shell Scripting | Set 1
    Consider a situation if we want to store 1000 numbers and perform operations on them. If we use a simple variable concept then we have to create 1000 variables and perform operations on them. But it is difficult to handle a large number of variables. So, it is good to store the same type of values i
    6 min read

    Control Structures

    Conditional Statements | Shell Script
    Conditional Statements: There are total 5 conditional statements which can be used in bash programming if statement if-else statement if..elif..else..fi statement (Else If ladder) if..then..else..if..then..fi..fi..(Nested if) switch statement Their description with syntax is as follows: if statement
    3 min read
    Looping Statements | Shell Script
    Looping Statements in Shell Scripting: There are total 3 looping statements that can be used in bash programming  Table of Content `while` statement in Shell Script in Linux`for` statement in Shell Script in Linux`until` statement in Shell Script in LinuxExamples of Looping StatementsTo alter the fl
    10 min read
    Break and Continue Keywords in Linux with Examples
    Both “break” and “continue” are used to transfer control of the program to another part of the program. It is used within loops to alter the flow of the loop and terminate the loop or skip the current iteration. break The break statement is used to terminate the loop and can be used within a while,
    3 min read

    Functions and Script Organization

    Shell Scripting - Functions and it's types
    Shell scripting is a powerful tool used to automate tasks in Unix-like operating systems. A shell serves as a command-line interpreter, and shell scripts often perform file manipulation, program execution, and text output. Here, we'll look into functions in shell scripting, exploring their structure
    5 min read
    How To Pass and Parse Linux Bash Script Arguments and Parameters
    Parsing and Passing of Arguments into bash scripts/ shell scripts is quite similar to the way in which we pass arguments to the functions inside Bash scripts. We'll see the actual process of passing on the arguments to a script and also look at the way to access those arguments inside the script. Pa
    7 min read

    Input And Output

    Shell Scripting - Standard Input, Output and Error
    Working on Linux applications we have several ways to get information from outside and to put it inside: command line args, environment variables, files. All of these sources are legal and good. But it has a finite size. Another way to establish communication is standard streams: input stream (stdin
    7 min read
    Shell Script to Perform Operations on a File
    Most of the time, we use shell scripting to interact with the files. Shell scripting offers some operators as well as some commands to check and perform different properties and functionalities associated with the file. For our convenience, we create a file named 'geeks.txt' and another .sh file (or
    5 min read

    Command-Line Arguments and Options

    Shell Script to Demonstrate Special Parameters With Example
    Here, we are going to see what are the special Parameters of the shell script. Before that first, let's understand what is parameters in the shell. The parameter is the entity that stores the value. The variables are the parameters that are defined by the user to use in that specific shell script. A
    5 min read

    Error Handling and Debugging

    User Space Debugging Tools in Linux
    In this article, we will discuss debugging tools in Linux. Debugging Tools are those programs that allow us to monitor, control, and correct other program's error while they execute. Some of the debugging tools are as follows:- 'print Statement'Querying (/proc, /sys etc)Tracing (strace/ltrace)Valgri
    3 min read
    Shell Scripting - System Logging
    Shell scripting is a way of automating tasks and operations on a computer system by writing scripts and programs in a shell or terminal environment. These scripts can run commands, access system resources, and process data. Shell scripts are often used to automate repetitive tasks, such as backups,
    9 min read

    Regular Expressions

    How to Use Regular Expressions (RegEx) on Linux
    Regexps are acronyms for regular expressions. Regular expressions are special characters or sets of characters that help us to search for data and match the complex pattern. Regexps are most commonly used with the Linux commands:- grep, sed, tr, vi. The following are some basic regular expressions:
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences