Summary of Linux packaging and compression commands
Summary of Linux packaging and compression commands
There are many types of compressed files in Linux, so various packaging and compression commands are also dazzled. I have never liked hard writing, so I will try to summarize it:
In Linux, there are two types of compressed files:
1) tar
2) In other windows systems, such as zip and rar
1. First we will be familiar with tar
Among these types, tar is the heaviest component and plays the most roles. Therefore, you can also say that you are familiar with tar and are familiar with Linux packaging and compression; of course, tar is essentially a Linux Command, so it is important to understand the parameter meaning of this command:
Tar has many parameters, but only a few are commonly used. We need to know the following:
(One parameter is required ")
-C: Create a compressed file
-X: Extract
-T: View content
-R: append an object to the end of the compressed file.
-U: update the file in the original compressed file
The compression or decompression command must contain one of the above five parameters (and only one is required). The following five parameters are optional and can be selected together:
(The second-level parameter "optional or optional ")
-Z: With the gzip attribute
-J: With the bz2 attribute
-Z: Has the compress attribute (different from the first lower case)
-V: displays all processes.
-O: unbind the file to the standard output
The last-parameter is required. In addition, only file names can be followed:
("Required and unique ")
-F
In this way, we can get some example commands as follows: (in the example command, you can change whether to package or compress by modifying the first parameter (c-> x)
(Without adding second-class parameters)
Tar-cf all.tar *. jpg: this command is used to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.-f specifies the package file name.
Tar-rf all.tar *. gif: This command adds all. gif files to the package of all.tar. -R indicates adding files.
Tar-uf all.tar logo.gif: this command is used to update the logo.gif file in tarbao all.tar.tar.-u indicates the Update file.
Tar-tf all.tar: this command is used to list all files in the all.tar package.-t is used to list objects.
Tar-xf all.tar: this command is used to extract all files in the all.tar package.-x is used to unlock the files.
(With the second-class parameter)
Tar-cvf jpg.tar *. jpg // pack all jpg files in the Directory into tar.jpg
Tar-czf jpg.tar.gz *. jpg // jpg
Tar-cjf jpg.tar.bz2 *. jpg // jpg
Tar-cZf jpg.tar. Z *. jpg // jpg. Z
By adding the second type of parameters (of course, the specific z, j, and Z), we can distinguish whether tar has called other compressed files with two suffixes, such as. Z.
Second, let's take a look at the. Zip and. rar compressed files in windows.
Linux also has corresponding methods for packaging and compressing.
1. ZIP file
Linux provides the zip Command, which has many parameters and is not described in detail.
Compression: zip all.zip *. jpg
Decompress: unzip all.jpg
22.16.rar
To install rar in Linux, you need to install RAR for Linux, which needs to be downloaded from the Internet and seems to be charged. After installation, there are two programs, rar and unrar:
Compression: rar a all *. jpg: this command is to compress all. jpg files into a rarpackage named all.rar. the program automatically attaches the. rar extension name to the package name.
Decompress: unrar e all.rar: this command is used to extract all files from all.rar.
Iii. Example commands that save time and effort
Now we have finished compressing and extracting all the files. Let's take a look at the example that saves time and effort:
The following examples show how to decompress the package (the first parameter (c-> x) can be changed in the example command to package or compress ):
. Tar package: tar-xvf file.tar
.Tar.gz package: tar -xzvffile.tar.gz
.Tar.bz2 package: tar -xjvffile.tar.bz2
. Tar. Z: tar-xZvf file.tar. Z
. Rar package: unrar efile.rar
. Zip package: unzip file.zip
. Gz package: gunzip all.gz
.Tgzor .tar.gz package: tar-xzfall. tgz & tar-xzf all.tar.gz
. Bz2 package: bunzip2all.bz2
. Z package: uncompress all. Z
Summary
1. Decompress *. tar with tar-xvf
2. Use gzip-d or gunzip to decompress *. gz
3. Use tar-xzf to decompress * .tar.gz and *. tgz.
4. Use bzip2-d for *. bz2 or use bunzip2 for decompression.
5. Use tar-xjf to decompress * .tar.bz2
6. Use uncompress to decompress *. Z
7. Decompress *. tar. Z with tar-xZf
8. Extract files using unrar e for *. rar
9. Decompress *. zip with unzip