Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.

In the manpage, it says:


   install [OPTION]... [-T] SOURCE DEST
   install [OPTION]... SOURCE... DIRECTORY
   install [OPTION]... -t DIRECTORY SOURCE...
   install [OPTION]... -d DIRECTORY...

   -d, --directory
          treat all arguments as directory names; create all components of
          the specified directories

OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?

I tried doing a basic test by making an arbitrary directory structure on my local hard disk:

~>tree test
├── a
│   └── b
│       └── c
│           └── e.txt
└── d

4 directories, 1 file

And then running install -d and looking at what was created:

~>install -d test test2
~>tree test2

0 directories, 0 files

Nothing happened!

Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.

share|improve this question
up vote 6 down vote accepted

It looks like the install -D command is actually what I want.


-D create all leading components of DEST except the last, then copy SOURCE to DEST

Works great, except you have to specify every file individually.

share|improve this answer
I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r – dtmland Jul 8 '15 at 20:11
Does the install command have an equivalent to cp -r? – Alexander Jul 8 at 10:53

install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp

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.