mkdir

Create one folder, several at once, or a whole path in one go with mkdir -p.

>_ Try it: a simulated Linux, right here
Loading the terminal…

Examples

  • mkdir projects
  • mkdir docs notes
  • mkdir -p site/css/fonts
  • ls site/css
  • ls -l

How it works

mkdir NAME makes a new folder inside the one you are in (pwd tells you which). It prints nothing when it works.

To create a folder inside folders that don't exist yet, add -p: mkdir -p site/css/fonts creates all three. Without it, mkdir says "No such file or directory".

Syntax

mkdir [-p] FOLDER...

Options

OptionWhat it does
-pmake the parent folders too, and don't complain if it already exists
A B Cseveral folders in one command

Good to know

  • mkdir -p is safe to run twice: plain mkdir on an existing folder says "File exists".
  • Names with spaces need quotes: mkdir "My Project". Most people avoid spaces in folder names on Linux.