How is install different from cp?

How is install different from a simple copy, cp or dd? I just compiled a little utility and want to add it to /usr/sbin so it becomes available via my PATH variable. Why use one vs the other?

Asked By: tarabyte


Install copies files with the default mode 755.

Install can be configured to set the owner or group of a file and/or the mode of a file.

Install can be configured to backup the original file before it is replaced.

Answered By: fd0

To “install” a binary compiled from source the best-practice would be to put it under the directory:


On some systems that path is already in your PATH variable, if not you can add it by adapting the PATH variable in one of your profile configuration files ~/.bashrc ~/.profile


dd is a low level copy tool that is mostly used to copy exactly sized blocks of the source which could be for example a file or a device.

cp is the common command to copy files and directories also recursively with the option -r and by preserving the permissions with the option -p.

install is mostly similar to cp but provides additionally the option to set the destination file properties directly without having to use chmod separately.

cp your files to /usr/local/bin and adapt the PATH variable if needed. That’s what I would do.

Answered By: cakuzo

The primary difference between install and cp is that if the destination file already exists install unlinks it first.

This difference is not pointed out in the manual pages. The things listed in the other answers also matter — both programs have different options, and also GNU install has different options than BSD install so portable Makefiles are limited to a common subset.

Why unlinking (which can be also done by rm before cp) matters? If you have a file with two hardlinks and modify it using one of the hardlinks, it’s modified also in the other place on the filesystem. But if you remove one of the hardlinks first and replace it with modified file, the other place keeps the original version.

More probable scenario is that you update a program or a library while it is in use. If the binary is unlinked first, it won’t affect the running program. Here is a nice post with more details:

Answered By: marcin