install

Install or upgrade software or back up data

Supplementary instructions

The install command is used to install or upgrade software or back up data, and its usage permissions are for all users. The install command is similar to the cp command and can copy files/directories to a specified location. However, install allows you to control the properties of the target file. install is usually used in a program's makefile, using it to copy the program to the target (installation) directory.

grammar

install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...

In the first two formats, will be copied to or multiple files will be copied to an existing , and the permission mode and owner/group will be set at the same time. In the third format, all specified directories and their home directories are created. The parameters that are required for long options are also required when using short options.

Options

--backup[=CONTROL]: Backup each existing destination file.
-b: Similar to --backup, but does not accept any parameters.
-c: (This option is not processed).
-d, --directory: All parameters are treated as directories, and all home directories of the specified directory will be created.
-D: Create all home directories before <destination>, then copy <source> to <destination>; useful in the first usage format.
-g, --group=group: Set the group to which the process belongs, instead of the group to which the process currently belongs.
-m, --mode=mode: Set the permission mode yourself (like chmod) instead of rwxr-xr-x.
-o, --owner=owner: Set the owner yourself (only applicable to superuser).
-p, --preserve-timestamps: Use the access/modification time of the <source> file as the time attribute of the corresponding destination file.
-s, --strip: Use the strip command to delete the symbol table, only applicable to the first and second usage formats.
-S, --suffix=suffix: Specify the <suffix> of the backup file by yourself.
-v, --verbose: Print the name of each file/directory as it is processed.
--help: Display this help message and exit.
--version: Display version information and exit.

Example

install -d [option] DIRECTORY [DIRECTORY...]

Supports multiple, similar to mkdir -p which supports recursion. For example: install -d a/b/c e/f results the same as mkdir -p a/b/c e/f.

install [option] SOURCE DEST

Copy SOURCE file (test cannot be a directory) to DEST file:

install a/e c
The results are similar:
cp a/e c #Note that c must be a file.

Useful options -D:

install -D x a/b/c
The effect is similar to:
mkdir -p a/b && cp x a/b/c
install [option] SOURCE [SOURCE...] DIRECTORY

Copy multiple SOURCE files to the destination directory:

install a/*d

where d is the directory.