Linux-Beginners Series - Part 8_ Compression and Decompression

1. gzip/gunzip command

gzip is used to compress files (only files can be compressed into *.gz files)

gunzip is used to decompress files

Basic syntax:
gizp 文件
gunzip 文件.gz
Practice:
[root@bogon ~]# ls
1                ddd   huanghun              zhang.txt  视频  下载
aaa              dir1  initial-setup-ks.cfg  公共       图片  音乐
anaconda-ks.cfg  eee   zhang                 模板       文档  桌面
[root@bogon ~]# gzip zhang.txt
[root@bogon ~]# ls
1                ddd   huanghun              zhang.txt.gz  视频  下载
aaa              dir1  initial-setup-ks.cfg  公共          图片  音乐
anaconda-ks.cfg  eee   zhang                 模板          文档  桌面
[root@bogon ~]# gunzip zhang.txt.gz
[root@bogon ~]# ls
1                ddd   huanghun              zhang.txt  视频  下载
aaa              dir1  initial-setup-ks.cfg  公共       图片  音乐
anaconda-ks.cfg  eee   zhang                 模板       文档  桌面
[root@bogon ~]# 

Two, zip/unzip command

zip is used to compress files (a command to compress files and directories)

unzip is used to decompress files

Basic syntax:
zip [选项] xxx.zip
unzip [选项] xxx.zip
Common options
zip common options
serial number options illustrate
1 -r Recursive compression, i.e. compressed directories
unzip common options
serial number options illustrate
1 -d <directory> Specifies the storage directory of the decompressed files
Practice:
[root@bogon ~]# zip -r myaaa.zip huanghun
  adding: huanghun (stored 0%)
[root@bogon ~]# ls
1                ddd   huanghun              zhang      模板  文档  桌面
aaa              dir1  initial-setup-ks.cfg  zhang.txt  视频  下载
anaconda-ks.cfg  eee   myaaa.zip             公共       图片  音乐

Three, tar command

The tar command is a packaging command, and the final packaged file is a .tar.gz file.

basic grammar
tar [选项] xxx.tar.gz 打包的内容
Option Description
serial number options illustrate
1 -c Generate a .tar package file
2 -v show details
3 -f Specify the compressed file name
4 -z Pack and compress
5 -x Unpack the .tar file
Practice:
[root@bogon ~]# tar -zcvf pc.tar.gz zhang.txt
zhang.txt
[root@bogon ~]# ls
1                ddd   huanghun              pc.tar.gz  公共  图片  音乐
aaa              dir1  initial-setup-ks.cfg  zhang      模板  文档  桌面
anaconda-ks.cfg  eee   myaaa.zip             zhang.txt  视频  下载

Guess you like

Origin blog.csdn.net/m0_62181310/article/details/130323581