In many Linux commands, the install command and the cp command can copy files, but there are some differences in usage. Many people don't know how to choose when they use them. The following small series teaches you how to distinguish between the install command and the cp command.
The main difference between them is as follows:
1, the most important point, if the target file exists, cp will be cleared after the first file inside to write the new file, and install The original file will be deleted and then written to the new file. This is because writing to the file being used may cause some problems. For example, writing a file that is being executed may fail. For example, writing a new file to a file handle that has been continuously written may result in an error. file. And using install to delete and then write (will generate a new file handle) to install to avoid these problems;
2, install command will properly handle 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 suitable debug information, and will automatically handle the SElinux context.
------------------------------------ Split line ------ ------------------------------
At the time of compiling LFS 6, I still couldn’t understand install. What is the difference between a command and cp and chmod, chgrp?
After working, I realized that a running process can't just do cp, and often prompts "text busy". The advice given by the seniors of the operation and maintenance department is to use mv instead of cp. Today, it seems that the predecessors don't seem to Know the install command.
Now let's briefly introduce the install command.
install copy the file list and also set the file's properties (including owner, group), usually used in Makefiles To copy the program to the specified directory.
Common usages have the following three forms:
1: install -d [option] DIRECTORY [DIRECTORY..] Support multiple. Similar to mkdir -p supports recursion.
For example: install -da/b/ce/f The result is the same as mkdir -pa/b/ce/f.
2: install [option] SOURCE DEST< Br>
Copy the SOURCE file (test cannot be a directory) to the DEST file.
install a/ec The result is similar to cp a/ec # Note c must be a file.
Useful options -D
inst All -D xa/b/c # The effect is similar to mkdir -pa/b && cp xa/b/c
3: install [option] SOURCE [SOURCE..] DIRECTORY
Copy multiple SOURCE files to the destination directory.
install a/* d where d is the directory.
Useful options
-b : Automatic backup.
-m : Set permissions for the installation file
-p : Keep the timestamps of the file. That is, the timestaamps of the file are the same as the source file. When we want to use the mtime of the installation file to trace the build of the file. Time instead of installation time.
-s : Strip the symbol tables from installed binary executables.
-S : The suffix of the backup file.
install -S .bak new old #old The file is automatically mv is old.bak.
-v: verbose , prints the details of the install file.
`-c‘
Ignored; for compatibility with old Unix versions of `install’. # is compatible with the old version of Unix.
-C: (uppercase)
Install the file, but if the target file is the same as the source file (the judgment method needs to look at the code confirmation), skip it. The advantage of this is to be able to maintain the same file mtime.
The above is the introduction of the Linux install command and the cp command. The biggest difference is that when the copy target file exists, install can be deleted and used. In case the copy fails.
Using cobbler under Linux can quickly establish a Linux network installation enviro
Linux system can use the history command to view the history of instructions. In order to improve th
AIX is a UNIX-like operating system, and hacmp is a control application for AIX systems. When AIX su
The resolution of the computer screen allows us to look more comfortable when using
How to use the echo command in Linux?
RHEL6 changes the name of the asm disk by udev.
Beginners how to view the shell guide in Linux
How to install Autossh on Linux system
What should I do if libpng fails to compile after Gentoo upgrade?
Modify Linux password prompt it is based on a dictionary word What to do?
The specific steps of hard disk partitioning under Linux
Linux how to fix the kernel panic problem caused by glibc?
Linux detection and prevention of DDOS attacks skills
How CentOS 6 modifies disk quota limits
How does Win10 remove the uninstalled Modern app icon? Win10 removes the uninstalled Modern app
Where does Win10 turn on Bluetooth
Windows 8.1 common 9 questions and answers
Software execution protection software can not open win2003 system how to be good?
Win8 remote desktop connection is not how to do
Windows7 system shutdown, logout or restart button is gone. How to restore
How is the Win10 window displayed separately?
How does WinXP view computer usage records? See how the computer uses traces
Windows media player can't play this file?
How does Win10 set up printer sharing? Printer sharing graphic tutorial