Structures of Directory in Operating System
Last Updated :
27 Sep, 2024
A directory is a container that is used to contain folders and files. It organizes files and folders in a hierarchical manner. In other words, directories are like folders that help organize files on a computer. Just like you use folders to keep your papers and documents in order, the operating system uses directories to keep track of files and where they are stored. Different structures of directories can be used to organize these files, making it easier to find and manage them.
Understanding these directory structures is important because it helps in efficiently organizing and accessing files on your computer. Following are the logical structures of a directory, each providing a solution to the problem faced in the previous type of directory structure.

Different Types of Directory in OS
In an operating system, there are different types of directory structures that help organize and manage files efficiently.
Each type of directory has its own way of arranging files and directories, offering unique benefits and features.These are:
- Single-Level Directory
- Two-Level Directory
- Tree Structure/ Hierarchical Structure
- Acyclic Graph Structure
- General-Graph Directory Structure
1) Single-Level Directory
The single-level directory is the simplest directory structure. In it, all files are contained in the same directory which makes it easy to support and understand.
A single level directory has a significant limitation, however, when the number of files increases or when the system has more than one user. Since all the files are in the same directory, they must have a unique name. If two users call their dataset test, then the unique name rule violated.

Advantages
- Since it is a single directory, so its implementation is very easy.
- If the files are smaller in size, searching will become faster.
- The operations like file creation, searching, deletion, updating are very easy in such a directory structure.
- Logical Organization : Directory structures help to logically organize files and directories in a hierarchical structure. This provides an easy way to navigate and manage files, making it easier for users to access the data they need.
- Increased Efficiency: Directory structures can increase the efficiency of the file system by reducing the time required to search for files. This is because directory structures are optimized for fast file access, allowing users to quickly locate the file they need.
- Improved Security : Directory structures can provide better security for files by allowing access to be restricted at the directory level. This helps to prevent unauthorized access to sensitive data and ensures that important files are protected.
- Facilitates Backup and Recovery : Directory structures make it easier to backup and recover files in the event of a system failure or data loss. By storing related files in the same directory, it is easier to locate and backup all the files that need to be protected.
- Scalability: Directory structures are scalable, making it easy to add new directories and files as needed. This helps to accommodate growth in the system and makes it easier to manage large amounts of data.
Disadvantages
- There may chance of name collision because two files can have the same name.
- Searching will become time taking if the directory is large.
- This can not group the same type of files together.
2) Two-Level Directory
As we have seen, a single level directory often leads to confusion of files names among different users. The solution to this problem is to create a separate directory for each user.
In the two-level directory structure, each user has their own user files directory (UFD). The UFDs have similar structures, but each lists only the files of a single user. System’s master file directory (MFD) is searched whenever a new user id is created.

Two-Levels Directory Structure
Advantages
- The main advantage is there can be more than two files with same name, and would be very helpful if there are multiple users.
- A security would be there which would prevent user to access other user’s files.
- Searching of the files becomes very easy in this directory structure.
Disadvantages
- As there is advantage of security, there is also disadvantage that the user cannot share the file with the other users.
- Unlike the advantage users can create their own files, users don’t have the ability to create subdirectories.
- Scalability is not possible because one user can’t group the same types of files together.
3) Tree Structure/ Hierarchical Structure
Tree directory structure of operating system is most commonly used in our personal computers. User can create files and subdirectories too, which was a disadvantage in the previous directory structures.
This directory structure resembles a real tree upside down, where the root directory is at the peak. This root contains all the directories for each user. The users can create subdirectories and even store files in their directory.
A user do not have access to the root directory data and cannot modify it. And, even in this directory the user do not have access to other user’s directories. The structure of tree directory is given below which shows how there are files and subdirectories in each user’s directory.

Tree/Hierarchical Directory Structure
Advantages
- This directory structure allows subdirectories inside a directory.
- The searching is easier.
- File sorting of important and unimportant becomes easier.
- This directory is more scalable than the other two directory structures explained.
Disadvantages
- As the user isn’t allowed to access other user’s directory, this prevents the file sharing among users.
- As the user has the capability to make subdirectories, if the number of subdirectories increase the searching may become complicated.
- Users cannot modify the root directory data.
- If files do not fit in one, they might have to be fit into other directories.
4) Acyclic Graph Structure
As we have seen the above three directory structures, where none of them have the capability to access one file from multiple directories. The file or the subdirectory could be accessed through the directory it was present in, but not from the other directory.
This problem is solved in acyclic graph directory structure, where a file in one directory can be accessed from multiple directories. In this way, the files could be shared in between the users. It is designed in a way that multiple directories point to a particular directory or file with the help of links.
In the below figure, this explanation can be nicely observed, where a file is shared between multiple users. If any user makes a change, it would be reflected to both the users.

Acyclic Graph Structure
Advantages
- Sharing of files and directories is allowed between multiple users.
- Searching becomes too easy.
- Flexibility is increased as file sharing and editing access is there for multiple users.
Disadvantages
- Because of the complex structure it has, it is difficult to implement this directory structure.
- The user must be very cautious to edit or even deletion of file as the file is accessed by multiple users.
- If we need to delete the file, then we need to delete all the references of the file inorder to delete it permanently.
5) General-Graph Directory Structure
Unlike the acyclic-graph directory, which avoids loops, the general-graph directory can have cycles, meaning a directory can contain paths that loop back to the starting point. This can make navigating and managing files more complex.

General Graph Directory Structure
In the above image, you can see that a cycle is formed in the User 2 directory. While this structure offers more flexibility, it is also more complicated to implement.
Advantages of General-Graph Directory
- More flexible than other directory structures.
- Allows cycles, meaning directories can loop back to each other.
Disadvantages of General-Graph Directory
- More expensive to implement compared to other solutions.
- Requires garbage collection to manage and clean up unused files and directories.
Conclusion
Understanding the different directory structures in an operating system is important for efficient file organization and management. Each structure, whether single-level, two-level, tree-structured, acyclic graph, or general graph, offers unique ways to arrange and access files. Choosing the right directory structure helps ensure that files are easy to find, use, and maintain.
Frequently Asked Questions on Directory Structure – FAQs
What is a root Directory?
A root directory is a fundamental concept in directory structure of OS. It is a parent directory that is a top-level directory organised in a hierarchical manner and is represented by a forward slash “/” in a unix like systems & a backslash in windows “\”.
What is a purpose of a directory structure?
The sole purpose of a directory structure is to provide a way to store and oragnise files & data in an efficient manner so that access and management of all the files can be done by the user in the simplest and productive manner.
What is a sub-directory ?
A sub-directory is a directory inside another directory. Inside a directory structure, a user can create many directories inside a directory. These are called sub-directories.
What are some common directory structures used in Operating System?
Most common directory structures used to store and organise files are – Single-Level, Two-Level, tree-like directory structures. Tree structure is generally used in modern personal computers.
What are most common system calls made while managing files through a directory structure?
Following system calls are majorly used :
- mkdir() : this system call is made when creating a new file through GUI or through command line
- open() : This call is made when opening a file inside a directory structure
- close() : This call is made when we close a file in a directory structure
- unlink() : This call is made to unlike a file from other directories before deleting it
- rmdir : This call is made to remove a directory from a file system
Similar Reads
Virtual Memory | Questions
Advantages Large virtual memory. More efficient use of memory. Unconstrained multiprogramming. There is no limit on degree of multiprogramming. Disadvantages Number of tables and amount of processor overhead for handling page interrupts are greater than in the case of the simple paged management tec
2 min read
Mealy and Moore Machines in TOC
Moore and Mealy Machines are Transducers that help in producing outputs based on the input of the current state or previous state. In this article we are going to discuss Moore Machines and Mealy Machines, the difference between these two machinesas well as Conversion from Moore to Mealy and Convers
3 min read
Difference between Multi-tasking and Multi-threading
Multi-tasking is the ability of an operating system to run multiple processes or tasks concurrently, sharing the same processor and other resources. In multitasking, the operating system divides the CPU time between multiple tasks, allowing them to execute simultaneously. Each task is assigned a tim
6 min read
Advantages and Disadvantages of various CPU scheduling algorithms
CPU Scheduling involves many different scheduling algorithms which have their Advantages and Disadvantages. 1. First Come First Serve (FCFS): Advantages: It is simple and easy to understand. FCFS provides fairness by treating all processes equally and giving them an equal opportunity to run. FCFS gu
3 min read
NPDA for accepting the language L = {am bn cp dq | m+n=p+q ; m,n,p,q>=1}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem - Design a non deterministic PDA for accepting the language L = {[Tex]a^m[/Tex] [Tex]b^n[/Tex] [Tex]c^p[/Tex] [Tex]d^q[/Tex] | m + n = p + q : m, n, p, q>=1}, i.e., L = {abcd, abbcdd, abbccd, abbbccdd, ......} I
2 min read
Internet of Things (IoT) | Set 2
Internet of Things (IoT) is a system of interconnected objects, usually called smart devices, through the Internet. The object can be a heart monitor, a remote, or an automobile with built-in sensors. That is objects that have been assigned an IP address and have the capability to collect and transf
11 min read
Difference between Volume Testing and Load Testing
Volume Testing: Volume Testing is a type of software testing that is performed to test the performance or behavior of the system or application under the huge amount of data. Volume testing is also called flood testing and it is a type of performance testing. Load Testing: Load Testing is a type of
2 min read
Difference between Internet, Intranet and Extranet
Networks are crucial in today’s globalized world because they allow the acquisition, exchange, and organization of knowledge. Of all the first order networks the Internet, Intranet, and Extranet are commonly utilized for various applications. Every network type meets specific roles that are required
5 min read
Difference between Opening and Closing in Digital Image Processing
Opening and Closing are dual operations used in Digital Image Processing for restoring an eroded image. Opening is generally used to restore or recover the original image to the maximum possible extent. Closing is generally used to smoother the contour of the distorted image and fuse back the narrow
2 min read
Difference between HDFS and NFS
In this article, we are going to discuss the difference between HDFS(Hadoop distributed file system) and NFS (Network file system). HDFS (Hadoop distributed file system) :It is a distributed file system that handles a large set of data that is running on commodity hardware and in which data is distr
3 min read
Difference between Snowflake Schema and Fact Constellation Schema
Snowflake Schema: Snowflake Schema is a type of multidimensional model. It is used for data warehouse. In snowflake schema contains the fact table, dimension tables and one or more than tables for each dimension table. Snowflake schema is a normalized form of star schema which reduce the redundancy
4 min read
Pin diagram of 8051 Microcontroller
Introduction : The 8051 microcontroller is a popular 8-bit microcontroller widely used in embedded systems. It is a single-chip microcontroller with a Harvard architecture that includes a CPU, RAM, ROM, and several peripherals. The 8051 microcontroller has a 40-pin dual in-line package (DIP) that pr
9 min read
Difference Between JVM and DVM
JVM is the virtual machine that runs java code on different platforms. It acts as an abstract layer between the program and the platform on which the java code is running. The portability of Java code is possible only because of the JVM. The javac compiler converts the source code file(.java file) i
3 min read
Difference between Cellular and Wi-Fi Networks
Wi-Fi is a technology that provides internet connectivity using radio waves. And through this we do not need wire cable to use internet on our devices.Cellular network is a type of wireless network made up of many cells through which mobile devices communicate with each other.both facilitate interne
6 min read
Difference between Amazon S3 and Wasabi
1. Amazon S3: Amazon S3 stands for Amazon Simple Storage Service. It is a cloud storage service that is provided by Amazon Web Services. It provides object storage through a web service interface. It allows for the storage of any type of objects like data lakes for analytics, data archives, backup a
2 min read
Difference between Broadband and Baseband Transmission
In communication systems, Broadband and Baseband refer to two different ways of transmitting data. They differ in how data is sent over a communication medium, the frequency range they use, and their applications.Broadband systems use modulation techniques to reduce the effect of noise in the enviro
6 min read
Difference between Adabas and AgensGraph
1. Adabas : The Adabas stands for an Adaptable Database System. It was developed by Software AG to run on IBM mainframes. It was launched in 1971. It is an OLTP-DBMS for mainframes and Linux/Unix/Windows environments. Adabas is an enterprise database management system (DBMS) designed for reliability
2 min read
Python - Check if substring present in string
The task is to check if a specific substring is present within a larger string. Python offers several methods to perform this check, from simple string methods to more advanced techniques. In this article, we'll explore these different methods to efficiently perform this check. Using in operatorThis
2 min read
Periodic Signals
Periodic Signals are an important tool in the electronic industry. They are unavoidable in modern electronics and are almost used in every daily appliance for generating signals that repeat their behavior after a certain period. In this article, we will study what is a periodic signal, how does it l
9 min read