Linux file compression and archiving tools

Source: Internet
Author: User
Tags file copy unpack uncompress

1, compress/uncompress. Z format

compress [-DFVCVR] [-B maxbits] [file ...]

-D: uncompressed, equivalent to

-C: Result output to standard output, do not delete original file

Compress-c File > file. Z

-V: Show details

Uncompress decompression

-c-d file. Z > File-> extract, but keep the source file

Zcat file. Z >file


2, gzip/gunzip. gz format

gzip [OPTION] ... FILE ...

-D: Uncompressed, equivalent to Gunzip

-C: Output compressed or decompressed results to standard output (for preserving source files)

-#: 1-9, specify the compression ratio, the larger the value, the greater the compression ratio

Zcat: View text file contents without explicit decompression

Instance:

GZIP-C Messages >messages.gz

Gzip-c-D messages.gz > messages

Zcat messages.gz > messages

Bzip2/bunzip2/bzcat. bz2

3. bzip2 [OPTION] ... FILE ...

-k:keep, keep the original file

-D: Unzip

-#: 1-9, compression ratio, default = 6

Bzcat: View text file contents without explicit decompression


4, Xz/unxz/xzcat. XZ format

XZ [OPTION] ... FILE ...

-k:keep, keep the original file

-D: Unzip

-#: 1-9, compression ratio, default = 6

Xzcat: View text file contents without explicit decompression


5, Zip/unzip (support compression directory). Zip format

Packaging compression

Zip–r Sysconfig sysconfig/

Unpacking and decompression

Unzip Sysconfig.zip

Cat/var/log/messages | Zip message–

UNZIP-P Message > Message

6. Tar Archive tool

tar [OPTION] ...

(1) Create an archive

Tar-c-F Path/to/somefile.tar (output files) file (source file) ...

Tar Cf/path/to/somefile.tar (output files) file (source file) ...

-V Show verbose archiving process

When archiving, automatically remove the "/" at the beginning to avoid the time when the recovery is placed directly into the absolute path, covering the

Legacy data

(2) View the list of files in the archive file

Tar-t-f/path/to/somefile.tar

(3) Expand archive

Tar-x-f/path/to/somefile.tar

Tar-x-f/path/to/somefile.tar-c/path/

Tar is now supported for automatic identification with file format, below the-j-z, etc., can not input

Combined with compression tool implementation: Archive and Compress

-J:BZIP2,-z:gzip,-J:XZ

7, Cpio (it does not have compression function, only packaging)

Copy from or to a file

The Cpio command is a redirected way to package a file for backup, restore recovery

Tool that can decompress files ending with ". Cpio" or ". Tar".

cpio [Options] > file name or device name

Cpio [Options] < file name or device name

Options

-o Package a file copy into a file or export the file to the device

-I unpack, unzip the package file or restore the backup on the device to the system

-T Preview, view the contents of the file or output to the file on the device

-V Displays the file name during the packaging process.

-D Unpack the directory, and automatically build the directory when Cpio restore

-C A newer storage method

Example

To back up the ETC directory:

Find./etc-print |cpio-ov >etc.cpio

Content Preview

Cpio–tv < Etc.cpio

To unpack a file

Cpio–iv <etc.cpio

Cpio–idv < Etc.cpio


Linux file compression and archiving tools

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.