Menu
Coddy logo textTech

Create A Directory

Part of the Fundamentals section of Coddy's Terminal journey — lesson 16 of 82.

The mkdir command stands for make directory. It creates a new folder in your current location.

Simply type mkdir followed by the name of the folder you want to create:

mkdir projects

You can confirm it was created by running ls:

ls
documents
projects
readme.txt

Creating multiple directories at once:

You can create several folders in a single command by listing them separated by spaces:

mkdir projects documents backups

Creating nested directories:

Use the -p flag to create a directory and all its parent directories at once:

mkdir -p projects/app/src

Without -p, this would fail if projects or app don't already exist. With -p, all three folders are created automatically.

Note: Directory names follow the same rules as file names — avoid spaces and special characters. Use hyphens or underscores instead:

mkdir my-project    # ✅ good
mkdir my_project    # ✅ good
mkdir my project    # ❌ creates two folders: my and project
challenge icon

Challenge

Beginner

Create a new directory called projects in your current location, then use ls to confirm it was created.

Hint: Use the mkdir command followed by the directory name.

Cheat sheet

The mkdir command creates a new directory:

mkdir projects

Creating multiple directories:

mkdir projects documents backups

Creating nested directories with -p flag:

mkdir -p projects/app/src

The -p flag creates all parent directories automatically if they don't exist.

Naming conventions: Use hyphens or underscores instead of spaces:

mkdir my-project    # ✅ good
mkdir my_project    # ✅ good
mkdir my project    # ❌ creates two folders

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals