Tar
1) tar calls Gzip
Gzipis a program developed by gnuorganization. The file ending with .gz is the result of gzip compression. And Gzip
The relative decompression program is gunzip. Use the-Z parameter in tar to call gzip. The following is an example.
:
# Tar-CZF all.tar.gz *. jpg
This command is to compress all .jpg files into a tar package and use gzip to generate
The package name is all.tar.gz.
# Tar-xzf all.tar.gz
This command unlocks the generated package.
2) tar call Bzip2
Bzip2is a more powerful compression program. The file ending with .bz2 is the result of Bzip2 compression.
The decompress program relative to Bzip2 is bunzip2. Use the-J parameter in tar to call gzip. The following is an example.
Note:
# Tar-CJF all.tar.bz2 *. jpg
This command is to compress all .jpg files into a tar package and use Bzip2 to generate
Bzip2compressed package named all.tar.bz2
# Tar-xjf all.tar.bz2
This command unlocks the generated package.
3) tar call Compress
Compress is also a compression program, but it seems that people who use compress are not as good as those who use gzip and Bzip2.
More .. The file ending with Z is the result of Bzip2 compression. The decompress program relative to compress is uncompress.
. Use the-Z parameter in tar to call compress. The following is an example:
# Tar-CZF all.tar. z *. jpg
This command is to compress all .jpg files into a tar package and generate
An uncompress compressed package named all.tar. Z
# Tar-xzf all.tar. Z
This command is used to unbind the generated package.
--------------------------------------------- Detailed command parameter description ----------------------------------------------------------------------------------------------------------------
-C: Create a compressed file
-X: Extract
-T: View content
-R: append an object to the end of the compressed archive object
-U: update files in the original compressed package
These five are independent commands, one of which must be used for compression and decompression. They can be used with other commands, but only one of them can be used. The following parameters are optional when files are compressed or decompressed as needed.
-Z: With the gzip attribute
-J: With the bz2 attribute
-Z: With the compress attribute
-V: displays all processes.
-O: unbind the file to the standard output
The following parameter-F is required
-F: use the file name. Remember, this parameter is the last parameter and can only be followed by the file name.
# Tar-CF all.tar *. jpg
This command is 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.-u indicates that the file is updated.
# 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 the files in the all.tar package.
Compression
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
Rar a jpg.rar *. jpg // RAR format compression, You need to download RAR for Linux
Zip jpg.zip *. jpg // ZIP format compression, You need to download zip for Linux first
Extract
Tar-xvf file.tar // decompress the tar package
Tar-xzvf file.tar.gz // decompress tar.gz
Tar-xjvf file.tar.bz2 // unzip tar.bz2
Tar-xzvf file.tar. Z // extract tar. Z
Unrar e file.rar // extract RAR
Unzip file.zip // decompress the ZIP file
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
Gzip command
There are two obvious advantages to reduce the file size. One is to reduce the storage space, and the other is to reduce the transmission time when the file is transmitted over the network. Gzip is a frequently used command in Linux to compress and decompress files, which is convenient and easy to use.
Syntax: gzip [Option] compressed (decompressed) file name the meaning of each option of this command is as follows:
-C writes the output to the standard output and keeps the original file. -D. decompress the compressed file. -L the following fields are displayed for each compressed file: size of the compressed file, size of the uncompressed file, and compression ratio; name of the uncompressed file-r recursively searches for the specified directory and compresses all the files or decompress them. -T test to check whether the compressed file is complete. -V displays the file name and compression ratio for each compressed and decompressed file. -Num uses the specified numeric num to adjust the compression speed.-1 or -- fast indicates the fastest compression method (low compression ratio), and-9 or -- best indicates the slowest compression method (high compression ratio ). The default value is 6. Command instance:
Gzip * % compresses each file in the current directory into A. GZ file. Gzip-DV * % decompress each compressed file in the current directory and list detailed information. Gzip-L * % detailed information of each compressed file in Example 1 is displayed without decompression. Gzip usr.tar %: the compressed tar backup file usr.tar. the extension name of the compressed file is .tar.gz.