Directory Structures - aryanjoshi0823/5143-Operating-System GitHub Wiki

A directory is a container used to organize files and folders in a hierarchical structure, similar to physical folders for documents. Operating systems use directories to efficiently store and manage files.

Different Types of Directory in OS:

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.

2) Two-Level Directory:

  • 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.

  • 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

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.