Introduction to compression packaging, gzip compression tool, bzip2 compression tool, xz compression tool

Introduction to compression packaging

Compressing files saves bandwidth.

Common compressed files

  • windows -.rar   .zip   .7z
  • linux-.zip ,.gz,  .bz2,  .xz, .tar.gz ,  tar.bz2, tar.xz


gzip compression tool

Usage: gzip [filename] cannot compress directory

[root@glinux-01 tmp]# gzip test.sh
[root@glinux-01 tmp]# ls
dnsmasq.conf
newdisk
systemd-private-d14dd3227c904734b33abb6fb75fae17-chronyd.service-Bh9orh
systemd-private-d14dd3227c904734b33abb6fb75fae17-vgauthd.service-98O2TY
systemd-private-d14dd3227c904734b33abb6fb75fae17-vmtoolsd.service-bJJp1G
test.sh.gz       //Compressed file

Unzip: gzip -d [filename]

[root@glinux-01 tmp]# gzip -d test.sh.gz
[root@glinux-01 tmp]# ls
dnsmasq.conf
newdisk
systemd-private-d14dd3227c904734b33abb6fb75fae17-chronyd.service-Bh9orh
systemd-private-d14dd3227c904734b33abb6fb75fae17-vgauthd.service-98O2TY
systemd-private-d14dd3227c904734b33abb6fb75fae17-vmtoolsd.service-bJJp1G
test.sh           //decompression

Option gzip - (1 ~ 9) specifies the compression level. The larger the level is, the smaller the compression is. However, the higher the cpu consumption is, the default level is 6.

View the compressed file information file [file name]

[root@glinux-01 tmp]# file test.sh.gz
test.sh.gz: gzip compressed data, was "test.sh", from Unix, last modified: Sat Feb 24 13:48:09 2018

View the compressed file content zcat [file name]

[root@glinux-01 tmp]# zcat test.sh.gz
#
# Default /etc/sudo.conf file
#
# Format:
#   Plugin plugin_name plugin_path plugin_options ...
#   Path askpass /path/to/askpass
#   Path noexec /path/to/sudo_noexec.so
#   Debug sudo /var/log/sudo_debug all@warn
#   Set disable_coredump true

Compress the file but keep the original gzip - C test.sh > / TMP / test.sh.gz

[root@glinux-01 tmp]# gzip -c test.sh > /tmp/test.sh.gz
[root@glinux-01 tmp]# ls
dnsmasq.conf
newdisk
systemd-private-d14dd3227c904734b33abb6fb75fae17-chronyd.service-Bh9orh
systemd-private-d14dd3227c904734b33abb6fb75fae17-vgauthd.service-98O2TY
systemd-private-d14dd3227c904734b33abb6fb75fae17-vmtoolsd.service-bJJp1G
test.sh
test.sh.gz

bzip2 compression tool

Better than gzip compression, but more cpu intensive

Install the tool yum install -y bzip2 first

The usage is the same as gzip, and the directory cannot be compressed.

Bzip2 - ා (1-9) compression level defaults to 9

bzcat view the contents of the compressed file.

xz compression tool

Tags: sudo Windows Linux Unix

Posted on Tue, 31 Mar 2020 22:25:35 -0700 by topflight