mkdir Make directories
Creates one or more new folders. You reach for it when you set up a project, a backup location or any place to put files. It will not overwrite or change anything that already exists.
Synopsis
mkdir [-pv] [-m MODE] DIRECTORY...
Common options
| Option or form | What it does |
|---|---|
-p | Create any missing parent folders as well. It also stops complaining if the folder already exists |
-v | Verbose: print each folder as it is created |
-m MODE | Set the permissions of the new folder, for example -m 700 for owner-only access |
Examples
mkdir backup
mkdir reports archive drafts
mkdir -p build/out/logs
mkdir -p docs
mkdir -m 700 private
mkdir -p project/{src,tests,docs}
Notes
- Without -p, mkdir fails if the parent folder does not exist, and fails if the folder already exists. With -p, both cases are fine, which makes it good for scripts that can run more than once.
- Brace expansion such as {src,tests} is done by the shell, not by mkdir. It works in bash and zsh, but it is not guaranteed in plain sh, and a shell without it creates one folder literally named {src,tests}.
- Names with spaces need quotes, for example mkdir "My Folder". Without quotes you get two folders.
- New folders get permissions of 777 reduced by your umask, so they are usually 755. With -m, the mode is applied to the final folder only. With -p the parent folders it creates get the default permissions.
- The -v option is not part of the POSIX standard, so avoid it in scripts that must run on every system. GNU mkdir has it too.
See also
Last reviewed 2026-10-07.