Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 37 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


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.