Linux commands: Install

Source: Internet
Author: User

Introduction to the Install command:

the Install command works by installing or upgrading software or backing up data, and its use rights are for all users.

Install command -copy files and set attributes (properties)


1. command format:

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


2. Command function:

   2. Use
     The install command works by installing or upgrading software or backing up data, and its use rights are for all users.
   2. Format
    (1) Install [options] ... Source destination
    (2) Install [options] ... Source... Directory
    (3) install-d [options] ... Directory...
    In the first two formats, the < source > is copied to < destination > or multiple < source > files are copied to the existing < directory, and both the permission mode and the owner/owning group are set. In the third format, all the specified directories and their home directories are created. The parameters that must be used for the long option are also required when using the short option.

   3. Main parameters
    --backup[=control]: A backup of 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 processed as directories, and all home directories for the specified directory are created.
    -D: Create all home directories < destinations >, and then copy < source > to < destinations >; in the first use format.
    -g,--group= Group: Sets the owning group itself, not the group to which the process currently belongs.
    -m,--mode= mode: Set your own permission mode (like chmod) instead of rwxr-xr-x.
    -o,--owner= owner: Self-setting owner (for Superuser only).
    -p,--preserve-timestamps: The time attribute of the corresponding destination file with the access/modification time of the < source > file.
    -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: Prints the name when each file/directory is processed.
    --help: Displays this help message and leaves.
    --version: Displays the version information and leaves.



Attached: The difference between the install command and the CP command in Linux

Basically, the install will be used in the makefile, and the CP command will be used elsewhere.

They accomplish the same task-copying files, the differences between them are 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 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.

install-copy files and set attributes

Install the attributes at the same time as the copy.

So try to use the install command in makefile.

install-copy files and set attributes

Install the attributes at the same time as the copy.

so try to use the install command in makefile.

For example

@install-D/usr/bin

@install-P-d-m 0755 targets/usr/bin

equivalent

@mkdir-P/usr/bin

      @cp targets/usr/bin                

@chmod 755/usr/bin/targets <----update file permissions

@touch/usr/bin/tagets <----update file timestamp

The Install command is great.

In addition, the @ prefix means that the results are not output from the console.


Linux commands: Install

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.