################################################
The following compression deletes the original file and only compresses the file
Gzip
-D: Unzip
-#:1-9 Compression ratio
Compression
[Email protected]/]# Gzip/tmp/txt.txt
Decompression Method 1
[Email protected]/]# gzip-d/tmp/txt.txt
Decompression Method 2
[Email protected]/]# guzip-d/tmp/txt.txt
View the contents of a text file without being pressed
[Email protected]/]# zcat/tmp/txt.txt.gz
################################################
Bzip2
-D: Unzip
-#:1-9 compression ratio, default 6
-K: Compress retention of original files
Compression
[Email protected]/]# Bzip2/tmp/txt.txt
Extract
[Email protected]/]# bzip2-d/tmp/txt.txt.bz2
View Compressed file contents
[Email protected]/]# bzcat/tmp/txt.txt.bz2
################################################
XZ. XZ
-D: Unzip
-#:1-9 compression ratio, default 6
-K: Compress retention of original files
Unxz
Xzcat
################################################
Zip: Archive and compress
Compress files, do not delete original files
[Email protected] tmp]# zip test4.zip txt*.txt
[Email protected] tmp]# Unzip Test4.zip
################################################
Tar: Archive-only uncompressed
-C: Create an archive file
-F Filename.tar: Archived files for operations
-X: Expand Archive file
--xatrrs: Preserve extended properties of files when archiving
-T: View archived content, do not expand
-ZXF: Archive and invoke gzip compression
TAR-ZXF txt.tar.gz
-ZXF: Call gzip to unzip and expand archive
-JXF: Archive and call bzip2 compression
TAR-JXF txt.tar.bz2
-JXF: Call bzip2 to unzip and expand archive
-JXF: Archive and invoke XZ compression
TAR-JXF txt.tar.xz file File1 file1
-JXF: Call XZ to unzip and expand archive
################################################
Archive files, do not delete files
[Email protected] tmp]# TAR-CF Txt.tar txt*.txt
################################################
Expand archived Content
[Email protected] tmp]# RM-RF txt*.txt
[Email protected] tmp]# TAR-XF Txt.tar
[email protected] tmp]# LL
Total Dosage 44
DRWX------. 2 root root 16384 July 00:21 lost+found
Drwxr-xr-x. 2 root root 4096 December 1 19:49 test
-rw-r--r--. 1 root root 418 December 1 19:50 test.zip
-rw-r--r--. 1 root root 0 December 1 19:56 txt1.txt
-rw-r--r--. 1 root root 0 December 1 19:56 txt2.txt
-rw-r--r--. 1 root root 0 December 1 19:56 txt3.txt
-rw-r--r--. 1 root root 10240 December 1 19:57 Txt.tar
################################################
Do not expand view
[Email protected] tmp]# TAR-TF Txt.tar
Txt1.txt
Txt2.txt
Txt3.txt
Txt.txt
-rw-r--r--. 1 root root 1846 December 1 19:30 txt.txt
-rw-r--r--. 1 root root 58 December 1 19:30 txt.txt.bz2
Cpio: Archive Tool
This article is from the "Jameszhan Linux Advanced ops" blog, so be sure to keep this source http://jameszhan.blog.51cto.com/10980469/1879666
Linux Essentials-26, compression and archiving