Common Linux compression commands

Source: Internet
Author: User
(I) Principles of compression technology:

-- Principle 1
Because 1 byte = 8 bit, each byte has 8 memory units, and each memory unit can be 0, 1. When we record the number 1, seven bits should be "null ". However, to meet the needs of our current OS data access,
Therefore, the data is converted into bytes for record. Some compression technologies are used to "resize" the space to reduce the space occupied by files.
-- Principle 2
Record duplicate data. For example, if your data has 100 records, the compression technology will record "100 records 1" instead of actually having 100 records 1 bits.

 

(Ii) Introduction to various compression commands I Gzip
Syntax:
Gzip [-DV] File Name
Parameters:
-D: extracted Parameters
-V: Display compression ratio

Example:

[root@localhost Desktop]# gzip show_space.sql [root@localhost Desktop]# gzip -d show_space.sql.gz 

 

Ⅱ Bzip2
Syntax:
Bzip2 [-dkzv] File Name
Parameters:
-D: extract parameters.
-K: Keep the source file
-Z: Compression Parameters
-V: Display compression ratio

Example:
[root@localhost Desktop]# bzip2 -z show_space.sql [root@localhost Desktop]# bzip2 -d show_space.sql.bz2 [root@localhost Desktop]# bzip2 -zk show_space.sql 

 

Ⅲ tar
Whether or not the files packaged by tar are compressed is named differently.
For example, tar-CV-F file.tar. This file is called tarfile.
For example, tar-JCV-F file.tar.bz2. This file is called tarball)

Syntax:
Compression: name of the file or directory to be compressed by tar-JCV-F filename.tar.bz2
Query: tar-jtv-F filename.tar.bz2
Decompress: tar-jxv-F filename.tar.bz2-C directory to be decompressed
If it is .gz, change J to Z.

Example:
[root@localhost Desktop]# tar -jcv -f think.tar.bz2 show_space.sql show_space.sql[root@localhost Desktop]# tar -jxv -f think.tar.bz2  -C /root/Desktopshow_space.sql

 

IV cpio
CIPO and data stream redirection

Syntax:
Backup: cpio-ovcb>
Restoration: cpio-ivcdu <

Example:
[root@localhost Desktop]# find  | cpio -ovcB > /home/oracle/desktop.cpio[root@localhost Desktop]# cpio -idvc /home/think  < /home/oracle/desktop.cpio

 

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.