Install and CP are similar, you can copy files/directories to the specified location. However, the install allows you to control the properties of the target file. The install is usually used for the makefile of the program, which is used to copy the program to the target (installation) directory.
Install (1) User Commands Install (1)
NAME
install-copy files and set attributes
Synopsis
Install [OPTION] ... [-T] SOURCE DEST
Install [OPTION] ... SOURCE ... DIRECTORY
Install [OPTION] ...-t DIRECTORY SOURCE ...
Install [OPTION] ...-d DIRECTORY ...
...
One main parameter:
-d,--directory: All parameters are processed as directories, and all home directories for the specified directory are created.
-g,--group= Group: Sets the owning group itself, not the group to which the process currently belongs.
-s,--strip: Remove the symbol table with the strip command only for the first and second use formats.
-s,--suffix= suffix: Specify the < suffix > for the backup file yourself.
-v,--verbose: Print the details of the install file.
The main differences between the two-install command and the CP command:
1, the most important point, if the target file exists, CP will first empty the file to write a new file, and install will delete the original file and then write a new file. This is because writing to a file that is in use can cause problems , such as writing to an executing file that might fail, such as writing a new file to a file handle that has been continuously written to produce the wrong file. The installation can be avoided by using install to delete and then write (generate a new file handle) .
2. The install command will properly handle the issue of file permissions. For example, INSTALL-C will set the permissions of the target file to Rwxr-xr-x;
3, the Install command can print more appropriate debug information, but also automatically handle the SELinux context problem.
Basic usage of install command in Linux