Linux compression and archiving

Source: Internet
Author: User

There are several ways to compress under Linux: gzip, bzip2, XZ, zip

Gzip

The compressed file ends in. GZ,

Only files can be compressed and directories cannot be compressed
Usage:

Gzip:/path/to/somefile is used to compress, the original file will be deleted when finished
-D Decompression
-#: 1-9 To specify compression ratio eg:-9
Gunzip/path/to/somefile used to decompress, delete the original compressed file when finished
Zcat ZipFile Viewing compressed file contents

BZIP2:

The compressed file ends with a. bz2

Only files can be compressed and directories cannot be compressed
A greater compression ratio than gzip, only files can be compressed, folders cannot be compressed
Same as GZIP usage
-K can retain the original file when compressing,
Bzcat ZipFile Viewing compressed file contents

Zip:

Can compress the directory

Usage:

Zip compressed file name to compress files 1, files to compress 2

Unzip the file name to unzip
Do not delete the original file

Archive operations under Linux use the TAR command

Archiving is to put several files in a file with a. tar suffix

Usage: TAR-CF filename.tar file1,file2 .... Used to archive files

TAR-XF Filename.tar do not expand the archive and directly view which files are archived

-C: Create an archive file
-F File.tar Generated archive file
-X Expand Archive file
--xattrs: Preserves extended attribute information for files when archiving
-T: Do not expand the archive to directly see which files are archived

Tar can call each of the compression command implementations to both archive and compress.
-ZCF: Archive and invoke gzip compression
-ZXF: Call gzip to unzip and expand the archive, the-Z option can be omitted because the tar command can identify the compression tool used by the archive file according to the file suffix name (previous-can be omitted)
Similarly:-JCF: Call bzip2 Archive
-JXF: Call bzip2 Extract

Linux compression and archiving

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.