Back to course

17. Creating Directories: The `mkdir` Command

Linux Basics: From Zero to CLI Hero

Organizing Your Files

The mkdir command (Make Directory) is used to create new directories (folders).

Basic Creation

To create a single directory named Scripts in your current location:

bash $ mkdir Scripts $ ls Scripts Desktop Documents ...

Creating Multiple Directories

You can create several directories at once by listing their names:

bash $ mkdir project_A project_B project_C

Creating Nested Directories (-p)

If you need to create a directory structure where the parent directories don't exist yet, you must use the -p (parents) option.

Example: Creating ~/project/src/models

bash

This will fail if 'project' or 'src' don't exist:

$ mkdir project/src/models

This succeeds, creating all necessary parents:

$ mkdir -p project/src/models