Home > Wiki Tips

Understanding the mkdir Command: How to Create Directories in macOS

Updated on Sunday, June 8, 2025

iBoysoft author Yvonne Feng

Written by

Yvonne Feng
Professional tech editor

Approved by

Jessica Shee

English Français Deutsch やまと Español Português Türkçe

Summary: Learn what the mkdir command does and how to use it to create new and nested folders on your Mac using Terminal.

summary-mkdir-command

mkdir stands for "make directory," and it allows you to quickly create folders without opening Finder.  Whether you're organizing project files, writing scripts, or setting up directory structures for development, mkdir is an essential command.  

In this article, you'll learn what the mkdir command does and how to use it efficiently on a Mac.

How to create a new folder using the command

If you need to create multiple folders, using Terminal is much faster than clicking around with a mouse. If you are familiar with the command line, typing a single command is far more efficient than manually creating each folder through Finder. 

Below are the methods to create one or multiple folders on a Mac using the mkdir command. After running the command, you can use pwd to check the current directory where the folders were created.

Create a new folder

To create a single folder in your current directory, simply enter the following command. This will create a folder named my_project in your current location. If a folder with that name already exists, you'll get an error, so try a different name if needed:

mkdir my_project

Create multiple folders at once

You can also create several folders at the same time by listing their names with spaces in between. For example, the command below will create folder1, folder2, and folder3 all at once:

mkdir folder1 folder2 folder3

Create nested folders (multi-level directories)

If you want to create folders inside folders (a nested structure), use the -p option. This flag ensures that any necessary parent directories are created automatically. 

For example, the following command will create a folder called project, with a src folder inside it, and a components folder inside src—even if none of them previously existed:

mkdir -p project/src/components

Share this article with more people if you like it!

 

What is the mkdir command used for

The mkdir command is widely used in macOS, Linux, and Unix-like systems. It lets you organize files and manage your file system efficiently without relying on a graphical interface.

Creating specific directories allows you to group related files for easier access and management. When dealing with large amounts of data or multiple projects, mkdir can help you build a clean and organized folder structure. For example, you might use it to organize code repositories or separate media files into different folders.

The mkdir command is also useful for creating complex directory structures. With the -p option, you can create multiple directories at once, even if some parent folders don't exist yet. This makes it easy to build entire directory trees in a single command.

In addition, mkdir is commonly used in automation and scripting. By adding it to shell scripts, you can automatically create directories as part of larger workflows, saving your time.

Share to let more people know the mkdir command!