Author: Dave McKay / Source: How-To Geek

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.
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.

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
A programmer is working on just such a new utility, called ana
. It consists of an executable binary file and a database. After testing, it must be copied to /usr/local/bin
to make it available for all users of the Linux system. You’ll need to substitute the filenames and directory paths in our example for the files and paths you’re using on your computer when you use install
.
Until it is ready for release it will be tested in a directory called ~/test/ana
. Members of the geek
group will have read and execute permissions. Other users will have read and execute permissions also. The install
command uses the same numeric representation for permissions as chmod
does. Our programmer has decided that the permissions must be set to:
- Owner: Read, write, and execute.
- Group: Read and execute.
- Others: Execute only.
How to Use the install
Command
Our fictional programmer’s working directory is ~/work
. He has written the program, compiled it, and produced a binary called ana
. He already created the database file that ana
works with, Words.db
. So both files are ready for testing. Let’s take a look at them:
ls -l ana Words.db

The ana
utility he has just written creates anagrams out of a phrase provided on the command line. Verification testing is quite straightforward.

Our programmer has invoked ana
with the phrase “biscuit” and all seems well. He now wants to copy these two files to the ~/test/ana
directory to see if the new utility functions correctly away from the development environment. He issues the following command:
install -D -v ana Words.db -t ~/test/ana

The options used on the command line were:
- D: Create directories, including parent directories, if required.
- v: Verbose, list each directory as it is made and each file copy as it is…
The post How to Copy Files Using the “install” Command on Linux appeared first on FeedBox.