Linux 'Install' Command

Copy files in Linux with the 'Install' command

Close up of woman's hands using laptop at home
Andreas Larsson / Getty Images

The install command on Linux systems is used to copy files, and it does this by combining several commands into one to make them easy to use. The install command utilizes the cp, chown, chmod, and strip commands.

The install command should not be used to install applications that are already prepared for use though. Those should be downloaded and installed with the apt-get command.

Install Command Syntax

Below is the proper syntax to use for the install command.

The first three are used to copy a source to a destination that already exists, while also designating permissions. The final one is used to create all components of the given directory or directories.

install [OPTION]... -d DIRECTORY

These are the options you can use with the install command:

  • --backup[=CONTROL] makes a backup of each existing destination file
  • -b is like --backup but does not accept an argument
  • -c is (ignored)
  • -C should be used to install a file. That is, unless target already exists and is the same as the new file, in which case the modification time won't be changed.
  • -d, --directory will treat all arguments as directory names; create all components of the specified directories
  • -D creates all leading components of DEST except the last, then copies SOURCE to DEST. It's useful in the first format above.
  • -g, --group=GROUP sets group ownership
  • -m, --mode=MODE sets permission mode (as in chmod), instead of rwxr-xr-x
  • -o, --owner=OWNER sets ownership (super-user only)
  • -p, --preserve-timestamps applies access/modification times of SOURCE files to corresponding destination files
  • -s, --strip strips symbol tables. It's useful only for the first and second formats above.
  • -S, --suffix=SUFFIX overrides the usual backup suffix
  • -v, --verbose prints the name of each directory as it's created
  • -z, --context-CONTEXT sets SELinux security context of files and directories
  • --help displays help information and exits
  • --version outputs version information and exits

The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable.

These are the values:

  • none, off never make backups (even if --backup is given)
  • numbered, t makes numbered backups
  • existing, nil is numbered if numbered backups exist, otherwise it's simple
  • simple, never always make simple backups

The full documentation for install is maintained as a Texinfo manual. If the info and install programs are properly installed at your site, the command info install should give you access to the complete manual.

Important: Use the man command (% man) to see how a command is used on your particular computer.

Example of the Install Command

Following is one example of how to use the install Linux command to copy files. Each folder and file should be customized for your own situation.

install -D /source/folder/*.py /destination/folder

Here, the -D option is used to copy all the .py files from the /source/folder to the /destination/folder folder. Again, everything but "install" and "-D" should be altered to fit for your own files and folders.

If you need to make the destination folder, you can use this command (for our example here):

install -d /destination/folder