How to Create a New Folder in Terminal

How to Create a New Folder in Terminal

The quickest way to create a new folder in terminal is to use the mkdir command. In most shells on macOS, Linux, and Windows, you can type mkdir folder-name to make a new directory in the current location. You can also create nested folders, use names with spaces, and check that the folder was created with a listing command.

What command creates a new folder in terminal?

What command creates a new folder in terminal

The standard command is mkdir, short for “make directory.” It creates a new folder at the location you specify. If you only give a folder name, the folder is created in your current working directory. If you include a path, the folder is created there instead.

mkdir folder-name

Example: if you want a folder called Projects, run:

mkdir Projects

Create one folder

To create a single new folder, use mkdir followed by the folder name:

mkdir my-folder

This creates my-folder in the directory you are currently in. If you are not sure where that is, you can check with a directory listing command before or after creating the folder.

Useful notes for a single folder

  • Folder names are usually case-sensitive on Linux and often case-sensitive on macOS depending on the file system.
  • If a folder with the same name already exists, mkdir usually returns an error instead of overwriting it.
  • You can create the folder anywhere you have permission to write.

Create nested folders

If you want to create a folder inside another folder, you can include the full path. For example:

mkdir parent-folder/child-folder

That command creates child-folder inside parent-folder, but only if parent-folder already exists. If the parent folder does not exist, the command fails unless you use the -p option.

mkdir -p parent-folder/child-folder

The -p option tells the system to create any missing parent directories along the path. This is one of the most useful variations when you want to build a folder structure quickly.

Example of creating multiple levels at once

Example of creating multiple levels at once
mkdir -p website/assets/images

This creates website, then assets inside it, then images inside assets, if those folders do not already exist.

Create a folder with spaces in the name

Create a folder with spaces in the name

If a folder name contains spaces, put the name in quotes or escape the spaces. This avoids the terminal treating each word as a separate argument.

mkdir "New Folder"

Or:

mkdir New\ Folder

Both commands create a folder named New Folder. Quotation marks are usually easier to read, especially when folder names include multiple words.

Check that the folder was created

After running mkdir, you can verify the result with a directory listing command. The command depends on your operating system or shell.

SystemCommon listing commandWhat it does
macOS or LinuxlsShows files and folders in the current directory
Windows Command PromptdirShows files and folders in the current directory
Windows PowerShellGet-ChildItemLists files and folders in the current directory

Example on macOS or Linux:

mkdir reports
ls

Example on Windows Command Prompt:

mkdir reports
dir

Common errors and fixes

Most problems with creating folders in terminal come down to path issues, naming issues, or permissions. Here are the most common ones.

Permission denied

This usually means you do not have permission to create a folder in the current location. Try creating the folder somewhere you own, such as your home directory, or use an administrator account only if that is appropriate for your system and task.

Example:

cd ~
mkdir my-folder

No such file or directory

This often means part of the path you typed does not exist. If you are creating a nested folder, make sure the parent folder already exists, or use mkdir -p to create the full path.

mkdir -p parent/child

Folder already exists

If the folder name is already in use, mkdir will not create another folder with the same name in the same location. Choose a different name, or confirm whether the folder was already created earlier.

Spaces or special characters caused an error

Spaces or special characters caused an error

Use quotes around folder names with spaces, or escape individual spaces with a backslash. This is especially important in shells like bash and zsh.

Windows vs macOS vs Linux notes

The core idea is the same across all three platforms, but the terminal environment can differ slightly.

  • macOS: Terminal and iTerm typically use a shell such as zsh or bash, and mkdir works the same way.
  • Linux: Most distributions use bash, zsh, or another shell, and mkdir is standard.
  • Windows: In Command Prompt, PowerShell, and Windows Terminal, folder creation still works, but the surrounding shell commands for listing and navigation may differ.

The folder creation command itself is consistent enough that once you learn mkdir, you can use it in most terminal environments. The main differences are usually in path separators, quoting style, and the command you use to list files afterward.

Best practices when creating folders from terminal

  • Use clear folder names that describe the content or purpose.
  • Prefer hyphens or underscores instead of spaces when possible.
  • Use -p when creating a folder structure that may not exist yet.
  • Check your current directory before creating folders if location matters.
  • Be careful with absolute paths, especially when working in system directories.

Quick examples

# Create one folder
mkdir notes

# Create a folder with spaces
mkdir "Project Files"

# Create nested folders
mkdir -p work/client-assets/images

# Verify on macOS or Linux
ls

# Verify on Windows Command Prompt
dir

Frequently Asked Questions About how to create a new folder in terminal

What is the command to make a folder in terminal?

The most common command is mkdir. For example, mkdir Documents creates a new folder named Documents in the current directory.

How do I create a folder with spaces in the name?

Put the name in quotes, such as mkdir "New Folder", or escape each space with a backslash, such as mkdir New\ Folder.

How do I create nested folders in terminal?

Use the full path with mkdir -p, such as mkdir -p parent/child/grandchild. The -p option creates missing parent folders automatically.

Why is mkdir saying permission denied?

That usually means you do not have write access to the folder you are trying to use. Try a location where your account has permission, such as your home directory.

Does mkdir work on Windows Terminal, macOS, and Linux?

Yes. mkdir is widely supported across these systems. The command is the same, although related commands like listing folders may differ depending on the shell.

How can I tell if the folder was created successfully?

Run a listing command after mkdir, such as ls on macOS or Linux, dir in Command Prompt, or Get-ChildItem in PowerShell.

Final takeaway

If you want to know how to create a new folder in terminal, the core command is simple: use mkdir. For a basic folder, type mkdir folder-name. For nested folders, add -p. For names with spaces, use quotes. Once you know those three patterns, you can create folders quickly and reliably in most terminal environments.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *