Linux compression, decompression, and archiving tools

Source: Internet
Author: User

Compression, decompression, and archiving tools

Compress/uncompress:. Z
Gzip/gunzip:. gz
BZIP2/BUNZIP2:. bz2
XZ/UNXZ:. XZ
Zip/unzip
Tar, Cpio

1, Gzip/gunzip

gzip [OPTION] ... FILE ...
-D: Uncompressed, equivalent to Gunzip
-C: Outputs the result to standard output;
-#:1-9, specify the compression ratio;

Zcat: View text file contents without explicit expansion;
[Email protected] test]# ll-h
Total 24K
-rw-r--r--1 root root 18K Jul 15:42 functions
-RW-------1 root root 146 Jul 15:42 messages
[Email protected] test]# gzip messages
[email protected] test]# LL
Total 24
-rw-r--r--1 root root 18216 Jul 15:42 functions
-RW-------1 root root 15:42 messages.gz

[Email protected] test]# gunzip messages.gz
[email protected] test]# LL
Total 24
-rw-r--r--1 root root 18216 Jul 15:42 functions
-RW-------1 root root 146 Jul 15:42 messages

To keep the original file you can add the-c parameter
[Email protected] test]# GZIP-C messages > messages.gz
[email protected] test]# LL
Total 32
-rw-r--r--1 root root 18216 Jul 15:42 functions
-RW-------1 root root 146 Jul 15:42 messages
-rw-r--r--1 root root 15:48 messages.gz
-rw-r--r--1 root root 15:48 messages.gz2

Note: The original file of the Gzip/gunzip file was deleted oh!!!!!!!!!!!


2, Bzip2/bunzip2/bzcat

bzip2 [OPTION] ... FILE ...
-k:keep, keep the original documents;
-D: Unzip
-#:1-9, compression ratio, default is 6;

Bzcat: View text file contents without explicit expansion;
[Email protected] test]# BZIP2 messages
[Email protected] test]# ll-h
Total 36K
-rw-r--r--1 root root 18K Jul 15:42 functions
-RW-------1 root root 162 Jul 15:42 messages.bz2
-rw-r--r--1 root root 15:48 messages.gz
-rw-r--r--1 root root 15:48 messages.gz2
-rw-r--r--1 root root 0 Jul 15:49 messages.gzddd
-rw-r--r--1 root root 15:51 messages.gzdddddddd
[Email protected] test]# bzip2-d messages.bz2
[email protected] test]# LL
Total 36
-rw-r--r--1 root root 18216 Jul 15:42 functions
-RW-------1 root root 146 Jul 15:42 messages
-rw-r--r--1 root root 15:48 messages.gz
-rw-r--r--1 root root 15:48 messages.gz2
-rw-r--r--1 root root 0 Jul 15:49 messages.gzddd
-rw-r--r--1 root root 15:51 messages.gzdddddddd

Note: The original file of the bzip2/bunzip2/file was deleted oh!!!!!!!!!!!

3, Xz/unxz/xzcat

bzip2 [OPTION] ... FILE ...
-k:keep, keep the original documents;
-D: Unzip
-#:1-9, compression ratio, default is 6;

Xzcat: View text file contents without explicit expansion;
[Email protected] test]# XZ messages
[email protected] test]# LL
Total 36
-rw-r--r--1 root root 18216 Jul 15:42 functions
-rw-r--r--1 root root 15:48 messages.gz
-rw-r--r--1 root root 15:48 messages.gz2
-rw-r--r--1 root root 0 Jul 15:49 messages.gzddd
-rw-r--r--1 root root 15:51 messages.gzdddddddd
-RW-------1 root root 188 Jul 15:42 Messages.xz
[Email protected] test]# Unxz MESSAGES.XZ
[email protected] test]# LL
Total 36
-rw-r--r--1 root root 18216 Jul 15:42 functions
-RW-------1 root root 146 Jul 15:42 messages
-rw-r--r--1 root root 15:48 messages.gz
-rw-r--r--1 root root 15:48 messages.gz2
-rw-r--r--1 root root 0 Jul 15:49 messages.gzddd
-rw-r--r--1 root root 15:51 messages.gzdddddddd
Note: The original file of the xz/unxz/file was deleted oh!!!!!!!!!!!


4. Tar
tar [OPTION] ...

(1) Create an archive
Tar-c-f/path/to/somefile.tar FILE ...

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

(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/to/dir

Combined with compression tool implementation: Archive and Compress

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

This article is from the "Liang blog" blog, make sure to keep this source http://7038006.blog.51cto.com/7028006/1829380

Linux compression, decompression, 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.