Linux Study Notes-compression and decompression commands

Source: Internet
Author: User

Linux Study Notes-compression and decompression commands

. Zip format compression:

Zip compressed file name source file # compressed file zip-r compressed file name source directory # compressed directory

Decompress in. zip format:

Unzip compressed file unzipped. ZIP Format File

Note:
1) The zip command can compress files or compress directories.
2). The zip compression format is common in Linux and Windows systems.

. Gz format compression:

Gzip source file # compressed file, the source file will disappear gzip-c source File> compressed file name # compressed file, the source file will not disappear gzip-r directory # All the sub-files under the compressed directory, but the directory cannot be compressed

Decompress in. gz format:

Gzip-d compressed file uncompressed. GZ file gunzip compressed file uncompressed. GZ file gunzip-r directory uncompressed all .gz files under the Directory

Note:
1) the gzip command compresses all the sub-files in the directory.

. Bz2 format compression:

Bzip2 source file # compressed file, the source file will disappear bzip2-k source file # compressed file, the source file will not disappear

. Bz2 format decompression:

Bzip2-d compressed file # decompress the file, the compressed file will disappear, plus-k will not disappear bunzip2 compressed file # decompress the file, the compressed file will disappear, plus-k will not disappear

Note:
1) The bzip2 command cannot compress directories.

. Tar.gzand .tar.bz2 format compression:

Tar-zcvf: compressed file name source file or source directory; compressed file or directory: .tar.gz format tar-jcvf: compressed file name source file or source directory; compressed file or directory: .tar.bz2 format

Decompress in .tar.gzand .tar.bz2 format:

Tar-zxvf compressed file unzip uncompress .tar.gz Format File tar-jxvf compressed file unzip uncompress .tar.bz2 Format File

Note:The options behind the tar command are as follows.

"Tar-c" packaging "tar-v" shows the packaging process "tar-f" specifies the packaged file name "tar-x" for unpackaging, opposite to-c, "tar-z" is compressed into .tar.gz format, "tar-j" is compressed into .tar.bz2 format.

Below are several common examples of compression and decompression.

Common examples:

1) archive the log.txt file in. ZIP format, save the compressed file to the test directory, and decompress the compressed file under the test directory.

2) decompress the shdirectory into the. ZIP format, save the compressed file to the test directory, and decompress the compressed file under the test directory.

3) compress the log.txt file and shdirectory into the all.tar.gz file, and decompress the contents in the compressed file to the test directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.