In the Linux operating system, the compression and decompressing of the *. zip, *. tar, * .tar.gz, * .tar.bz2, *. tar. xz, *. jar, and * .7z formats are as follows: .tar.gz.tar.bz2

Source: Internet
Author: User
Tags tar unzip

In the Linux operating system, the compression and decompressing of the *. zip, *. tar, * .tar.gz, * .tar.bz2, *. tar. xz, *. jar, and * .7z formats are as follows: .tar.gz.tar.bz2
Zip Format

Compression: zip-r folder target file name. zip [original file/directory name] unzip: unzip folder original file name. zip

Note: The-r parameter indicates recursion.

Tar format (this format is only packaged, not compressed)
Package: tar-cvf release target file name. tar [original file name/directory name] Unpack: tar-xvf Release Original file name. tar

Note: The c parameter represents create (create), the x parameter represents extract (unpack), the v parameter represents verbose (detailed information), and the f parameter represents filename (file name ), therefore, the file name must be followed after f.

Tar.gz format

Method 1: Use the tar file that has been packaged earlier to directly use the compression command.

Compression: gzip unzip original file name. Tar unzip: gunzip unzip original file name. tar.gz

Method 2: Package, compress, decompress, and unpackage

Package and compress: tar-zcvf extension target file name .tar.gz [original file name/directory name] decompress and unpack: tar-zxvf extension original file name .tar.gz

Note: z indicates that gzip is used for compression/decompression.

Tar.bz2 format

Method 1: Use the packaged tar file to directly execute the compression command:

Compression: bzip2 unzip original file name. Tar unzip: bunzip2 unzip original file name. tar.bz2

Method 2: Package, compress, decompress, and unpackage

Package and compress: tar-jcvf unzip the target file name .tar.bz2 [original file name/directory name] decompress and unpack: tar-jxvf unzip original file name .tar.bz2

Note: lowercase j indicates that bzip2 is used for compression/decompression.

Tar. xz format

Method 1: Use the compressed tar file:

Compression: xz original file name. Tar unzip: unxz original file name. Tar. xz

Method 2: Package, compress, decompress, and unpackage

Package and compress: tar-Jcvf unzip the target file name. tar. xz [original file name/directory name] decompress and unpack: tar-Jxvf unzip original file name. tar. xz

Note: uppercase J indicates that the xz algorithm is used for compression/decompression.

Tar. Z format (outdated)

Method 1: Use the compressed tar file:

Compression: compress unzip original file name. Tar unzip: uncompress unzip original file name. Tar. Z

Method 2: Package, compress, decompress, and unpackage

Package and compress: tar-Zcvf unzip the target file name. tar. Z [original file name/directory name] decompress and unpack: tar-Zxvf unzip original file name. tar. Z

Note: uppercase Z indicates that the ncompress algorithm is used for compression and decompression. In addition, ncompress is the compression format of early Unix systems. However, due to the low compression ratio of ncompress, ncompress is outdated.

Jar format
Compression: jar-cvf [target file name]. jar [original file name/directory name] decompress: jar-xvf [original file name]. jar

Note: If the Java class library is packaged and there is a main class in the class library, you need to write a META-INF/MANIFEST. MF configuration file, the content is as follows:

Manifest-Version: 1.0Created-By: 1.6.0_27 (Sun Microsystems Inc.)Main-class: the_name_of_the_main_class_should_be_put_here

Then use the following command to package

Jar-cvfm [target file name]. jar META-INF/MANIFEST. MF [original file name/directory name]

In this way, you can use the "java-jar [file name]. jar" command to directly run the public static void main method in the main class.

7z format
Compression: 7z a. Target file name. 7z [original file name/directory name] unzip: 7z x Original file name. 7z

Note: This 7z decompression command supports the rar format, namely:

7z x Original file name.rar

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.