Compress and package CentOS documents.
.Rarcompressed file is not identified in linux, and .zip can be used in windows and Linux.
. Gz: Files compressed by gzip
. Bz2: Files compressed by bzip2 compression Tool
. Tar: A file packaged by the tar package. (Tar does not have the compression function, but only combines a directory into a file ).
.Tar.gz: first pack tar and then compress it by gzip.
.Tar.bz2: first pack tar and then compress it with bzip2.
. Tar. xz: tar is first packaged and then compressed by xz.
Gzip compression tool (the directory cannot be compressed, and an error is reported)
Gzip [-d #] filename
-D: used for decompression.
-#: Indicates the compression level. 1 indicates the worst, 9 indicates the best, and 6 indicates the default value.
Gzip 1.txt is compressed to 1.txt.gz, and the original file disappears.
Decompress the gzip-d 1.txt.gz file and the original file disappears.
Bzip2 compression tool (directory cannot be compressed)
Install bzip2: yum install-y bzip2
Bzip2 [-dz] filename
-D: Extract
-Z: compression (can be compressed with or without it)
Bzip2-z 1.txt is compressed into 1.txt.bz2, and the original file disappears.
Bzip-d 1.txt.bz2 decompress the file and the original file disappears.
Zx compressed file usage is the same as bzip2
Tar packaging tool: tar [-zjJxcvfpP] filename tar
-Z: gzip compression at the same time
-J: bzip2 compression at the same time
-J: Use xz to compress data at the same time.
-X: Indicates decompression.
-T: view the files in the tar package.
-C: Create a tar package
-V: Indicates visualization and shows which files are packaged.
-F: the root file name, indicating the compressed file name or the decompressed file name. If multiple parameters are combined, write the-f parameter to the end.
-P: use the original file attribute, the attributes before compression, and the attributes after compression. (Not commonly used)
-P: You can use absolute paths (not commonly used)
Tar-cf test.tar t1.txt t2.txt tt pack t1.txt, t2.txt, and ttas into the test.tar file.
Tar-cvf test.tar t1.txt t2.txt tt package t1.txt, t2.txt, and ttles into the test.tar file and display the packaged file.
Packaging + gzip Compression
Compress tar-czvf test.tar.gz test123 test123into the test.tar.gz file.
-Tf option to view the list of packages or compressed files
Tar-tf test.tar.gz contains the file list of test.tar.gz.
-Zxvf: Decompress the compressed package in the .tar.gz format.
Tar-zxvf test.tar.gz unzip
Package + bzip2 Compression
Tar-cjvf test.tar.bz2 test123
Tar-tf test.tar.bz2.
Tar-jxvf test.tar.bz2 unzip the package.
Zip compression yum install-y zip
Zip 1.txt.zip 1.txt 1.txtcompressed to 1.txt.zip
Zip test.zip test1/* compresses all files in test1 (in fact, only the second-level directories can be compressed)
Zip-r test.zip test11/compress all files in test1, including directories or files in the second-level directory.
Decompress the zip file (yum install-y unzip)
Unzip 1.txt.zip