Linux study notes _ 3_common Linux commands _ 5 _ compression and decompression commands

Source: Internet
Author: User
Compression and decompression commands: gz1, gzip [GNUzip]: bingzipgzip option [file] compressed file. after compression, the extension is gz, which is most commonly used in Linux, the & amp; 26684; feature of the most traditional and common software source code package: 1) only files can be compressed, not directories 2)

Compression and decompression commands:

. Gz

1. gzip [GNUzip]:/bin/gzip

Gzip option [file] // compressed file,The extension name after compression is .gz.Is the most common and traditional tool in Linux.

// Common software source code package formats

Features: 1) only files can be compressed and directories cannot be compressed.

2) do not retain the original file

E.g. gzipnewfile

2. gunzip [GNUzip]:/bin/gunzip

Or gzip-d

Decompress .gz

. Tar

3. tar:/bin/tar

Package the directory into a file,Generate .tar

If compression is performed at this time,Will generate .gz

Tar [option cvf] [Directory]

-C: The package file of pai.tar, required

-V: displays details.

-F: specifies the compressed file name, which is mandatory.

-Z: compress the package at the same time.

E.g. tar-cvfz dir1.tar.gz dir1 // package and compress dir into a file

Note: This one-step packaging and compression is not supported by all UNIX systems!

At this time: 1) package: tar-cf newdir.tar newdir

2) compression: gzipnewdir.tar

Or use a connector.

Attachment: file command: used to determine the file type

File [file name]

4. tar

Extract

-Xunpack the .tar file

-V: show details

-F: specifies the file to be decompressed.

-Z decompression

E.g. tar-zxf newdir4.tar.gz

Step by step gunzipnewdir.tar.gz

Tar-xvf newdir.tar

. Zip

5. zip:/usr/bin/zip

Windows and linuxare only generic. if the file size is not large, we recommend that you use. zip.

E.g. zipservices.zip/etc/services compressed files, and the source files are retained.

Services.zip is the compressed file name!

Zip-r newdir.zip test compressed Directory

Two major defects of gzip compensated by zip: 1) keep the source file

2) directory can be compressed

6. unzip/usr/bin/unzip

Extract

Above: unzipnewdir.zip

. Bz2

7. bzip2/usr/bin/bzip2

It is equivalent to an upgraded gzip version and is suitable for compressing large files.

Although only files can be compressed, the compression ratio is amazing,File name .bz2

Of course, it can also be used in combination with tar.

Bzip2 option [-k] [file name] // add-k to keep the source file, otherwise it will be the same as zip

8. bunzip2

Decompress the file, or use-k to retain the source compressed file.

Related Article

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.