Linux 'Install' Command

Copy files in Linux with the 'install' command

The install command on Linux systems copies files by combining several commands into one to make them easy to use. The install command uses 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 using your distribution's package-management system.

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

Install Command Syntax

The proper syntax for the install command includes options, a source file, and a destination file.

install [OPTION]... -d DIRECTORY

These are the options that govern 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 using 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.

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

Example of the Install Command

The following command offers an 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