Skip to main content

Command referencemkdir

mkdir command (Linux / bash / sh / zsh)

Linuxbashshzshfilebeginner

What it does

Create one or more directories. When people search for the mkdir command linux, they usually want mkdir's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Create one or more directories.

Syntax

mkdir [OPTION]... DIRECTORY...

Common options

Flag / optionMeaning
-pCreate missing parent directories and ignore existing ones.
-m MODESet permissions on creation.
-vReport each created directory.

Practical examples

Create folder

mkdir reports

Creates reports in the current directory.

Create parents

mkdir -p data/2026/september

Builds the full nested path.

Set mode

mkdir -m 750 private

Creates a directory with restricted permissions.

Linux ↔ Windows equivalent

Closest match: mkdir (Windows / CMD). Create a directory and any missing intermediate directories.

Common mistakes

  • Omitting `-p` when parent directories do not exist.
  • Using Windows backslashes in a Linux path.

FAQ

What does mkdir do in Linux?

Create one or more directories.

How do I use mkdir from the terminal?

Start with `mkdir [OPTION]... DIRECTORY...`, then choose only the options needed for the task.

What is a practical mkdir example?

Try `mkdir reports` — Creates reports in the current directory.

Can I use mkdir in a shell script?

Yes. mkdir works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.