files

mkdir

Creates one or more directories. Can create nested paths and set the mode of new directories in a single call.

mkdir [OPTION]... DIRECTORY...

Common flags

Flag Purpose
-p Create parent directories as needed; do not error if they exist
-m Set mode (permissions) on new directories
-v Print a message for each directory created

Examples

mkdir project

Create a single directory in the cwd

mkdir -p src/app/api/users

Create a nested path without failing on existing parents

mkdir -m 700 secrets

Create a directory readable only by its owner

mkdir -pv logs/{app,nginx,db}

Create multiple sibling directories at once via brace expansion

Gotcha

Brace expansion (logs/{a,b}) is a shell feature, not part of mkdir itself; it will not work if the shell is set to disable it.

Related commands

← All Linux commands · Linux cheat sheet