Usage: Install [options] ... [-t] source file destination file
Or: Install [options] ... Source file ... Directory
Or: Install [options] ...-t directory source files ...
Or: Install [options] ...-D directory ...
This install copies files (usually compiled files only) to the destination of your choice.
If you want to download and install an instantly available package on the Gnu/linux operating system,
You should use a package manager such as Yum (1) and Apt-get (1).
In the first three forms, copy the source file to the destination file or copy multiple source files to an existing directory
Both the ownership and permission modes are set in. In the fourth form, create all the components in the destination directory.
Parameters that must be used for long options are also required for short options.
--backup[=control] Create a backup for each file that already exists
-B is similar to--backup but does not accept parameters
-C (ignored)
-C,--compare compares each group of source and target files, and in some cases does not modify the target file
-D,--directory treats all parameters as directory names, and creates all components for the specified directory
-D Create all the necessary parent directories for the destination directory, and then copy the source files to the directory
-G, the--group= group sets its own group instead of the current group to which the process belongs
-M,--mode= mode sets the permission mode (like chmod) instead of Rwxr-xr-x
-O,--owner= owner set owner (for Superuser only)
-P,--preserve-timestamps modify the source file access/modification time to be consistent with the target file
-S,--strip disassembly symbol table
--strip-program= program specifies a program to disassemble a binary file
-S,--suffix= suffix overrides common backup file suffix
-T,--target-directory= directory to copy all parameters of the source file to the specified directory
-T,--no-target-directory treats the target file as a normal file
-V,--verbose displays the name of the directory when it is created
--preserve-context Maintain a SELinux security environment
-Z,--context=context setting SELinux security environment for files and directories
--HELP displays this help information and exits
--version display version information and exit
The suffix of the backup file is "~" unless the--suffix option or the Simple_backup_suffix
environment variable specified. Versioning can be done through the--backup option or the Version_control environment
Variable to select. The following are the available variable values:
None, off no backup (even with the--backup option)
Numbered, t backup files plus numbers to sort
Existing, nil if a digital backup file already exists, use a number, or use a normal way to back up
Simple, never always use normal way to back up
Cases:
The code is as follows:
[Root@linux ~]# install test.php ar_test #将test. PHP Copy to Ar_test below
< P>[root@linux ~]# Install-d Hao #创建目录
[Root@linux ~]# install-t hao UTF8 test.php #将utf8 test.php cp to Hao Directory
The difference between install commands and CP commands in Linux
Basically, the install is used in the makefile, and the CP command is used elsewhere.
They do the same task-copying files, and the difference between them is mainly as follows:
1, the most important point, if the target file exists, CP will first empty the file to write a new file, and install will first delete the original file and then write a new file. This is because writing to a file that you are working with may cause problems, such as writing to a file that is executing, such as writing a new file to a file handle that has been written continuously, resulting in an incorrect file. The problem can be avoided by using install to install 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 and more appropriate debug information and automatically handle problems with SELinux contexts.
The code is as follows:
install-copy files and set attributes
Install to make a copy of the same time, set the attributes.
So use the install command as much as possible in makefile.
For example
The code is as follows:
@install-D /usr/bin-p-d-m 0755 targets/usr/bin
Equivalent
The code is as follows:
@mkdir-P /usr/bin targets /usr/bin 755 /usr/bin/targets/usr/bin/tagets
< p;
Update file timestamp
Install command strong. The
also means that the @ prefix does not output results in the console.