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

Is there an easy way to create all subdirectories of a path in linux ?

Something like

 mkdir   /a/b/c/d/e/f  

executed in / should create directories a,b,c,d,e,f

share|improve this question

migrated from Dec 10 '10 at 0:03

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted

Just use:

mkdir -p /a/b/c/d/e/f

The -p tells mkdir to create parent directories if they dont exist and doesn't give an error if the directory(ies) already exist(s). I wouldn't really consider this to be recursive.

share|improve this answer
No error is given if the directory already exists. If it already exists and is not a directory (regular file, pipe, special, etc.) then you get an error. – robert Dec 9 '10 at 23:31

Use mkdir -p /a/b/c/d/e/f.

share|improve this answer

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.