OS Directory Operations

The allowed system calls for managing the directories exhibit more variation from system to system than system calls for the files.

Here are the list of some common samples taken from the UNIX system, shows what they are and how they work.

Here are the list of the common directory operations:

  • Create
  • Delete
  • Opendir
  • Closedir
  • Readdir
  • Rename
  • Link
  • Unlink

Let's describe briefly about all the above directory operations one by one.


A directory is created. It is empty except for dot and dotdot, which are put there automatically by the system.


A directory is delete. Here, only those directory can be deleted which are empty.


Directories can be read. But before reading any directory, it must be opened first.

Therefore to list all the files present in a directory, a listing program opens that required directory to read out the name of all files that this directory contains.


Directory should be closed just to free up the internal table space when it has been read.


This call returns the next entry in an open directory.


Directory can also be renamed just like the files.


Linking is a technique that allows a file to appear in more than one directory.


A directory entry is removed.

Operating System Online Test

« Previous Tutorial Next Tutorial »