linux-Compression and packaging

Source: Internet
Author: User
Tags bz2 file copy uncompress

Compression, decompression, and archiving tools

File-roller

Compress/uncompress:. Z

Gzip/gunzip:. gz

BZIP2/BUNZIP2:. bz2

XZ/UNXZ:. XZ

Zip/unzip

Tar

Cpio

Compress/uncompress

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

- D: decompression, equivalent to uncompress

C: results output to standard output , do not delete the original file

- V: Show Details

uncompress Unzip

Zcat file. Z >file

Gzip/gunzip

gzip [OPTION] ... FILE ...

- D: decompression, equivalent to Gunzip

C: outputs a compressed or decompressed result to a standard output

-# : 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

bzip2 [OPTION] ... FILE ...

-k:keep, keep the original file

- D : Unzip

-# : 1-9 , compression ratio, default is 9

Bzcat : View text file contents without explicit decompression

Xz/unxz/xzcat

XZ [OPTION] ... FILE ...

-k:keep, keep the original file

- D : Unzip

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

Xzcat: View text file contents without explicit decompression

Zip/unzip

Packaging compression

Zip-r/testdir/sysconfig/etc/sysconfig/

Unpacking and decompression

Unzip Sysconfig.zip

Cat/var/log/messages | Zip messages-

UNZIP-P Message > Message

Tar Tools

Tar ( Tape ARchive , the abbreviation for Tape archive)

tar [OPTION] ...

(1) Create an archive

Tar-cpvf/path/to/somefile.tar FILE ...

(2) append file to archive: Note: Append to compressed file is not supported

Tar-r-f/path/to/somefile.tar FILE ...

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

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

(4) Expand Archive

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

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

(5) combined with compression tool implementation: Archive and Compress

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

- T option to specify the input file ,-X option specifies a list of files to exclude

Tar zcvf mybackup.tgz-t/root/includefilelist-x/root/excludefilelist

split the Big Tar files are multiple small files:

Split-b size-d Tar-file-name Prefix-name

Split-b 1m-d mybackup.tgz Mybackup-parts

Split-b 1M mybackup.tgz Mybackup-parts

Merge:

Cat mybackup-parts* > mybackup.tar.gz

Cpio

Function: Copy file from or to archive

Cpio The command is a redirected way to package a file for backup, restore the recovery tool, which can be decompressed to " . Cpio "or" . Tar "End of file

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 a device

- I. Unpack the package files or restore the backups on the device to the system

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

- v displays the name of the file during the packaging process.

- D unpacking the build directory, Cpio when restoring, set up the directory automatically

- C a newer way to store

Example

will be etc Directory Backup:

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

Content Preview

Cpio-tv < Etc.cpio

Unpacking files

Cpio-idv < Etc.cpio

Compression ratio sort

Z

Gz

bz2

Xz

it 4 tool can only be compressed for files, Zip and the Tar to pack it, not to pack it. WinRAR words Zip in the Windows can also be used

Tar-cpvf

- C Create

- P Save Property

- v look at the process

-F

linux-Compression and packaging

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.