Gzip
Only files can be compressed, directories cannot be compressed, and source files are deleted after compression
Gzip: Compress the suffix. gz
-#:1-9 Specifies the compression ratio, which defaults to 6
-D: Unzip
[Email protected] study]# gzip messages #压缩完成后会删除源文件 [[email protected] study]# lltotal 8-RW-------. 1 root root 6828 Dec 22:22 messages.gz[[email protected] study]# gzip-d messages #解压缩 [[email protected] study]# Llto Tal 336-RW-------. 1 root root 340117 Dec 22:22 messages
Gzip Unzip
Gunzip
[[email protected] study]# gunzip messages.gz unzip [[email protected] study]# lltotal 336-RW-------. 1 root root 340117 Dec 22:22 messages
Zcat: No pressure gzip View gzip Compression Package Contents
[Email protected] study]# Zcat messages.gz
Bzip2
Bzip2 a larger compression ratio than gzip, only files can be compressed, and source files are deleted after compression
-K: Keep source files
compression [[email protected] study]# bzip2 messages [[email protected] study]# ls-lhtotal 8.0K-RW-------. 1 root root 4.8K Dec 22:22 messages.bz2
BUNZIP2: Decompression
[Email protected] study]# bunzip2 messages.bz2 [[email protected] study]# ls-lhtotal 336K-RW-------. 1 root root 333K Dec 22:22 messages
Bzcat: No pressure bzip2 View the contents of the compressed package
[Email protected] study]# Bzcat messages.bz2
Xz
The compression ratio is larger, the command format is the same as the above two
compression [[email protected] study]# XZ message[[email protected] study]# ls-lhtotal 8.0K-RW-------. 1 root root 4.9K Dec 22:22 messages.xz decompression [[email protected] study]# xz-d MESSAGES.XZ
Zip
Save source files By default after compression, support archive compression
zip filename.zip FILE1 FILE2 ...
[[email protected] study]# zip messages.zip messages #压缩单个文件 adding: messages (deflated 98%) [[email protected] study]# ls - LHTOTAL 344K-RW-------. 1 root root 333K Dec 23 22:22 Messages-rw-r--r--. 1 root root 6.9k dec 23 22:42 messages.zip[[email protected] study]# zip messages.zip messages messages01 messages02 #归档压缩多个文件 adding: messages (deflated 98%) adding: messages01 (deflated 98%) adding: messages02 (deflated 98%) [[email PROTECTED] STUDY]# LS -LHTOTAL 1.1M-RW-------. 1 root root 333K DEC 23 22:22 MESSAGES-RW-------. 1 root root 333K Dec 23 22:44 MESSAGES01-RW-------. 1 root root 333k dec 23 22:44 messages02-rw-r--r--. 1 root Root 21k dec 23 22:44 messages.zip
Unzip: Decompression
[Email protected] study]# unzip Messages.zip Archive:messages.zip inflating:messages inflating:mess Ages01 INFLATING:MESSAGES02 [[email protected] study]# ls-lhtotal 1.1M-RW-------. 1 root root 333K Dec 22:22 messages-rw-------. 1 root root 333K Dec 22:44 messages01-rw-------. 1 root root 333K Dec 22:44 messages02-rw-r--r--. 1 root root 21K Dec 22:44 messages.zip
Tar
Archive tool, only archive not compressed
-C: Create an archive file
-F File.tar: Manipulating archive files
--xattrs: Preserve file extension property information when archiving
-X: Unlocking the archive file
-T: Do not expand the archive to see which files are archived
-ZCF: Archive and invoke gzip compression
-ZXF: Archive and invoke gzip decompression
-JCF: Archive and call bzip2 compression
-JXF: Archive and invoke bzip2 decompression
-JCF: Archive and invoke XZ compression
-JXF: Archive and invoke XZ decompression
Archive and call XZ compression [[email protected] study]# TAR-JCVF messages.tar.xz messages[[email protected] study]# ls-lh-rw-r--r--. 1 root root 5056 Dec 22:56 messages.tar.xz Archive and invoke gzip compression [[email protected] study]# TAR-ZCVF messages.tar.gz messages[[e Mail protected] study]# ls-lh-rw-r--r--. 1 root root 6.8K Dec 22:58 messages.tar.gz
This article from "Liang Childe" blog, please be sure to keep this source http://iyull.blog.51cto.com/4664834/1885663
Linux Basics-Compression and archiving