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

How can I create several subfolders in folder in one command.

For example, I want to create:

/home/user/*create dir1*/*create dir2*/*create dir3*/

Provided, I don't have dir1. And I can't use 3 command, and can't use shell script. This creating must be in one shell command.

$ mkdir /home/user/TEST1/TEST2/TEST3/

Doesn't work, no such file error. If

$ mkdir /home/user/TEST1/
$ mkdir /home/user/TEST1/TEST2/
$ mkdir /home/user/TEST1/TEST2/TEST3/

That work's, but I can't implement that solution. I need to use just one command.

Could you give me answer for this trouble?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You are looking for the -p argument:

-p, --parents 
no error if existing, make parent directories as needed

so the command you need is:

$ mkdir /home/user/TEST1/TEST2/TEST3/ -p
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.