Making Directories

In this lesson, we introduce you to directories and show you how to make one.

Beyond files, a set of directory-related system calls enable you to make, read, and delete directories. Note you can never write to a directory directly. Because the format of the directory is considered file system metadata, the file system considers itself responsible for the integrity of directory data. Thus, you can only update a directory indirectly by, for example, creating files, directories, or other object types within it. In this way, the file system makes sure that directory contents are as expected.

To create a directory, a single system call, mkdir(), is available. The eponymous mkdir program can be used to create such a directory. Let’s take a look at what happens when we run the mkdir program to make a simple directory called foo:

Get hands-on with 1200+ tech skills courses.