Liinux Compression and archiving

Source: Internet
Author: User

Compression of files
AAAAAABBBBCCC compression becomes 6A4B3C
Compression tools:
Gzip/gunzip:. gz suffix
Only files can be compressed and directories cannot be compressed because they do not have archiving capabilities
Man gzip: View gzip command Help
Gunzip: Unzip Tool
LS-LH: Viewing File size
Gzip messages: Files that compress source files messages directly to the end of. GZ
Gunzip messages.gz: Re-unzip to file messages

Gzip option file name
-D is also available for decompression
gzip-d messages.gz: Re-unzip to file messages

-C compression while preserving the source file, the compressed data output as standard output, and redirect to the file, you can complete the compression
Gzip-c messages >> messages.gz: So you can have two files, compressed and uncompressed two files exist

-# 1-9 Compression ratio, the larger the number, the greater the compression ratio, the default compression ratio is 6
GZIP-7 messages: Press 7 to compress, the compressed file will be smaller

Zcat messages.gz: Directly read the contents of the file after gzip compression

BZIP2/BUNZIP2:. bz2 suffix
BZIP2 messages: Compressed file is messages.bz2
BUNZIP2 messages.bz2 extract to messages file

bzip2 option file name
-D is also available for decompression
gzip-d messages.gz: Re-unzip to file messages

-K compression preserves the source file, the compressed data output as standard output, and redirect to the file, you can complete the compression
Bzip2-k messages: This can have two files, compressed and uncompressed files exist

-# 1-9 Compression ratio, the larger the number, the greater the compression ratio, the default compression ratio is 6

Bzcat directly read the compressed file contents

Xz/unxz:. xz suffix
XZ messages
Unxz messages.xz

xz option file name
-D implementation unzip
-# 1-9 default is 6, the larger the number the greater the compression scale
-K is retained after compression Source file

Xzcat Direct Read compressed file contents

Zip/unzip:. zip suffix
Not only can compress files, but also can compress directories
Zip etc.zip etc/: Compressed directory etc
Unzip Etc.zip

Zip option after compressing the file name to compress the files or directories
-R compression directory, you must add the option that can be understood as recursive compression

File Archiving tool: Tar suffix for. Tar
Create an archive: The directory is packaged as a file
Tar options archived file name source file name
-C Create archive
-F Specify file name after file
TAR-CF Etc.tar etc/: Archive directory etc/for Etc.tar
-Z call gzip to compress archived files -j call bzip2 to compress the archived files
-j call XZ to compress the archived files
-P remove prompts during the command

Expand archive
Tar options archive file name
-X Expand Archive
-F Specify the file name after the archive
-Z call gzip to unzip the archived file
-j call bzip2 to unzip the archived file
-j call XZ to unzip the archived file
-C Specify the extracted directory
-p to remove the prompt in the process of removing the command
TAR-CF etc.tar/etc/: This will not succeed because it is the ETC
Tar cPf etc.tar/etc/in the root directory: This is a successful
tar xPf etc.tar:p is used to remove the hint

Archive and Compress:
TAR-CF etc.tar etc/: Archive
gzip Etc.tar: Post-compress, get etc.tar.gz
Merge into: tar-zcf etc.tar.gz etc/
Expand Archive: TAR-ZXF etc.tar.gz
bzip2 Etc.tar: Post-compression, get etc.tar.bz

Tar jcf etc.tar.bz2 etc/
Tar jxf etc.tar.bz2-c/home/







Liinux 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.