Linux Learning Notes Lesson nineth compression Packaging

Source: Internet
Author: User

One, gzip tool

Second, bZIP tools

Three, XZ tools

Four, zip and unzip

V. Tar



I, Gzip and zcat (-D,-N)

[[Email protected] ~] #gzip-9 install.log//compression level 1~9,1-faster,9-better

-rw-r--r--. 1 root root 3719 March 9 10:58 install.log.gz

[[Email protected] ~] #gzip-D install.log.gz//-D or Gunzip unzip,

[Email protected] ~]# Zcat 1.txt.gz
This was only bzip2 test!

After gzip file, file files will become File.zip


II, BZIP2 and Bzcat (-d-n)

[Email protected] ~]# bzip2 Install.log

-rw-r--r--. 1 root root 3298 March 9 10:58 install.log.bz2

[Email protected] ~]# bzip2-d install.log.bz2

[[email protected] ~]# bzcat 1.txt.bz2//bzcat View content
This was only bzip2 test!


Iii. XZ and Xzcat Tools

[Email protected] ~]# XZ 1.txt//

[email protected] ~]# LL | grep 1.txt

-rw-r--r--. 1 root root 80 March 14:47 1.txt.xz

[Email protected] ~]# Xzcat 1.TXT.XZ
This was only bzip2 test!
[Email protected] ~]# xz-d 1.TXT.XZ

[email protected] ~]# LL | grep 1.txt
-rw-r--r--. 1 root root 24 March 14:47 1.txt

[Email protected] ~]# XZ 1.txt 2.txt

[email protected] ~]# LL
Total Dosage 36
-rw-r--r--. 1 root root 80 March 14:47 1.txt.xz
-rw-r--r--. 1 root root 80 March 14:57 2.txt.xz

[Email protected] ~]# xz-d 1.txt.xz 2.txt.xz
[email protected] ~]# LL
Total Dosage 36
-rw-r--r--. 1 root root 24 March 14:47 1.txt
-rw-r--r--. 1 root root 24 March 14:57 2.txt


Four, zip and unzip

Zip is a compression tool, unzip is the unzip tool

Compressed files:

[[email protected] ~]# zip txt.zip 1.txt 2.txt
Adding:1.txt (stored 0%)
Adding:2.txt (stored 0%)

[email protected] ~]# LL
-rw-r--r--. 1 root root 346 March 15:20 txt.zip

[[email protected] ~]# zip-r dir.zip dir1/etc//-R compression Directory

[[email protected] ~]# unzip-l dir1.zip//View the list of compressed packages

[Email protected] ~]# Unzip dir.zip-d/tmp

[Email protected] ~]# ll/tmp
Total Dosage 8
Drwxr-xr-x. 2 root root 4096 March 16:00 Dir1
Drwxr-xr-x. 16:00 root root 4096 March


Five, tar packaging tools

Syntax: tar [-JXCVFPP] File

Package: TAR-CVF

-C: Build package,-V visualization,-F file name

-T: View the contents of the TAR Package

-C: Unzip to the specified directory:

[Email protected] ~]# TAR-CVF All.tar dir1 dir.zip etc

[Email protected] ~]# tar-u DIR2-VF all.tar/u: Add a new file in the package

[[email protected] ~]# TAR-TF All.tar//-T view the files in the tar package

[[email protected] ~]# tar-c/TMP-XVF All.tar//C extract to the specified directory

1. Use gzip compression while packaging:

TAR-CZVF test.tar.gz Test

TAR-XZVF TEST.TAR.GZ-C/tmp/-C unpack the package to the TMP directory

2, packaging and use bzip2 compression

TAR-CJVF all.tar.bz2 All

TAR-XJVF ALL.TAR.BZ2-C/tmp

3. Use XZ compression while packaging

TAR-JCVF all.tar.xz Dir1 Dir2 etc//package Dir1 Dir2 and etc

TAR-JXVF ALL.TAR.XZ

[Email protected] ~]# TAR-JXVF ALL.TAR.XZ-C/tmp

[Email protected] ~]# ll/tmp

Total Dosage 12
Drwxr-xr-x. 2 root root 4096 March 15:57 Dir1
Drwxr-xr-x. 2 root root 4096 March 16:05 Dir2
Drwxr-xr-x. 15:57 root root 4096 March

4 、--exclude exclude certain files

Tar--exclude *.d-zcvf etc.tar.gz/etc

TAR-TF etc.tar.gz | More

Tar--exclude *.d--exclude *.CONF-ZCVF etc.tar.gz/etc


This article is from the Linux Learning Notes blog, so be sure to keep this source http://genxin.blog.51cto.com/665191/1627092

Linux Learning Note nineth Lesson Compress package

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.