How to Copy Files Using the “install” Command on Linux

Share
  • April 19, 2019

install is a versatile file-copying command in Linux and macOS. It’s perfect for the power-user looking for efficiency. Read this article to discover how to work smarter—not harder.

Wait—It’s Not For Installing Software?

The install command might have the most misleading name of any of the Linux commands. It doesn’t actually install any software. If you’re trying to install a software package from the command line in Ubuntu or another Debian-based distribution use the apt-get command. On other Linux distributions, use your Linux distribution’s package management tool instead—for example, dnf on Fedora or zypper on openSUSE.

So What Does install Do?

In a nutshell  install combines elements from the cp (copy), chown (change owner), chmod (change mode), mkdir (make directory), and strip (strip symbols) commands. It lets you use functions from all of those in one single action.

The install command can:

  • Copy files like the cp command.
  • Choose whether to overwrite existing files.
  • Create the target directory if it does not exist, like mkdir.
  • Set the user permission flags of the files, just like the chmod command.
  • Set the owner of the files, just like the chown command.
  • Remove non-essential baggage from executable files, just like the strip command.

Despite all that functionality, the install command doesn’t have too many options to contend with.

install man page

When Would You Use It

The install command probably won’t be used every day. It’s useful, but only for certain situations. One scenario where install comes into its own is software development. Let’s say you’re programming a new utility. You’ll need to do testing outside of the development environment. To do that you need to copy the new program files to a test directory. The test directory might need to be created, and you need to set the correct permissions and ownership for the files.

Because development is an iterative activity, you can end up doing this sequence of actions many, many times. The install command does all the heavy lifting for you. Finally, when your new utility is ready to be deployed, you can use install to copy it with the correct permissions to its final working location.

An Example

Read the remaining 42 paragraphs

Source : How to Copy Files Using the “install” Command on Linux