Linux learning essay-compression and decompression, linux essay
. Gz files compressed by gzip
. Bz2 files compressed by bzip2 compression Tool
. Tar files packaged by the tar package
.Tar.gz is first packaged by tar and compressed by gzip.
.Tar.bz2 is first packaged by tar and compressed by bzip2
1: gzip file compression this command cannot compress Directories
Gzip + the file is compressed at the current position. gzip cannot compress the directory.
# Gzip 1.txt
Convert the compressed source file to 1.txt.gz.
Gzip-d file name indicates Decompression
# Gzip-d 1.txt.gz unzip and restore the file to 1.txt
2: bzip2 this command cannot compress Directories
# Bzip2 1.txt Compression
# Bzip2-d 1.txt.bz2 Extract
3: The tar compression tool can package and decompress directories and files simultaneously.
# Tar-cvf test.tar test/-c create a compressed package-v visualization-f compressed file name test/indicates the compressed directory or file
# Extract the 1.txt.tar file from tar-xvf 1.txt.tar
3.1: The-z option is required for gzip compression during packaging.
# Tar-czvf test.gz test/package the test directory and use gzip for compression
# Tar-xzvf test.gz-xzvf gzip package
3.2: During packaging, bzip2 only needs to be compressed with-j
# Tar-cjvf test.tar.bz2 test compressed test directory test.tar.bz2 use bzip2 Compression
# Tar-xjvf test.tar.bz2 decompression note-j is used here because the bz2 compressed package is decompressed
4: zip compression can be used to compress directories and files. When compressing directories, you must specify the files under the compression directory.
# Zip 1.txt.zip 1.txt compressing a single file
# Unzip 1.txt.zip unzip a single file
4.1 when you use the zip command to compress a directory, if there is a second-level directory under the first-level directory. You must add the-r option to compress the files in the second-level directory.
# Zip-r test.zip test /*