Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-22-2004, 01:53 PM   #1
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Rep: Reputation: 30
mkdir -p ?

I read the man pages about the command mkdir -p , I still am haveing trouble understanding it. Below is an excerpt from man mkdir
-p, --parents
Make any missing parent directories for each directory argument.
The mode for parent directories is set to the umask modified by
`u+wx'. Ignore arguments corresponding to existing directories.
(Thus, if a directory /a exists, then `mkdir /a' is an error,
but `mkdir -p /a' is not.)
Old 01-22-2004, 02:07 PM   #2
Registered: Jan 2004
Location: Gießen, Germany
Distribution: Xubuntu 12.04, Mythbuntu, Ubuntu Server 12.04
Posts: 174

Rep: Reputation: 24
Here is an example:

you already have a directory:


you want a subdirectory c, which is in b, which is in a:


A "mkdir /a/b/c" will fail, because it tries to create c in /a/b - and b does not yet exist.

You might use:

mkdir /a/b
mkdir /a/b/c

or simply

mkdir -p /a/b/c

which will create b, because it does not exist.
1 members found this post helpful.
Old 01-22-2004, 02:12 PM   #3
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Original Poster
Rep: Reputation: 30
thanks you made that very clear. I always thought their had to be an easier way of making a directory then multilple mkdir commands.
Old 10-19-2011, 05:23 AM   #4
LQ Newbie
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
Post 7 years later, from Google!

I am posting this here reply because this page is the first non-man answer for an "mkdir -p" query on Google.
To give some useful information/tip for all the noobs stumbling on here like I did.

You can use "mkdir -p" and the power of BRACES to create the biggest complexst hierarchies of directories you've ever dreamed of in one command!

Like so:
mkdir -p tmpdir/{trunk/sources/{includes,docs},branches,tags}
Which creates the following:
   |        |      |
branches   tags  trunk
              |          |
          includes     docs

Source: Wikipedia - mkdir

More info and examples here.

Last edited by Tinkster; 10-19-2011 at 12:40 PM. Reason: removed foul language
1 members found this post helpful.
Old 10-19-2011, 12:41 PM   #5
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
Introducing yourself to LQ by swearing in a necropost and
being reported for that. Nice. :}

And your version is simply a slightly more verbatious
explanation of the quote from the man-page in the first
response ...

Welcome, anyway.


Last edited by Tinkster; 10-19-2011 at 12:42 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mkdir recompilation puishor Programming 4 06-25-2005 05:37 PM
mkdir command digitalgravy Linux - General 5 08-12-2004 02:03 PM
mkdir help... Linux~Powered Linux - Software 2 06-13-2004 12:27 PM
mkdir doesn't work Kristian2 Slackware - Installation 7 06-10-2004 01:42 PM
mkdir help ITJedi Linux - Software 1 05-14-2004 06:19 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration