Take the 2-minute tour ×

What does the mkdir -p flag do? i.e the '-p' part?

share|improve this question
man mkdir, will give you the information. –  Johan Jul 19 '10 at 5:24
man pages suck. –  Daniel Smith Mar 19 '13 at 1:10
man, pages suck. –  Salem Jul 19 '13 at 18:28
man pages suck. someone can give an answer in 10 seconds compared to someone reading the man pages for 30+ minutes to find an answer. –  duckx Dec 16 '13 at 4:42

1 Answer 1

up vote 19 down vote accepted

-p Will create nested directories, but only if they don't exist already.

For example: suppose you have a directory /foo already that you have write permissions for.

mkdir -p /foo/bar/baz  # creates bar and baz within bar under existing /foo

It is also an idempotent operation, because if you run the same command over again, you will not get an error, but nothing will be created.

share|improve this answer
great, I couldn't find the flag in the man page when searching in Goog, strange! –  user27449 Jul 19 '10 at 4:35

Your Answer


