Linux packaging and compression commands

Currently, there are many commands for packaging and compression in  Linux  . The most commonly used methods are  zip , gzip , bzip 2 , xz , and tar.

1. zip compressed package 

//制作
//-r  递归 表示将指定的目录下的所有子目录以及文件一起处理
zip -r public.zip public

//解压
unzip public.zip
unzip public.zip -d dir

//查看
unzip -l public.zip

//安装 zip 减压软件
yum install -y unzip zip

2. gz compressed package : ( source code compression ) 

 The most commonly used packaging program under  Linux is tar .  Packages created using the  tar program are often called  tar packages. The commands for tar package files usually end with . tar . After the tar package is generated, other programs can be used. to compress, so let’s talk about the basic use of the tar command.        

//制作 gz 包
tar czvf public.tar.gz public

//解压 gz 包
tar xzvf public.tar.gz

//查看 gz 包
tar tf public.tar.gz

//制作 tar 包
tar cvf wwwroot.tar wwwroot  //仅打包,不压缩

//解压 tar 包
tar xvf wwwroot.tar

parameter:

Special note that in the parameter release,   only one c/x/t can exist! Cannot exist at the same time! Because it is impossible to compress and decompress at the same time

3.xz compressed package : 

I believe many people are unfamiliar with  xz  compression, but  xz is  a compression tool that comes with most  Linux by default.  The xz format is smaller than 7z . 

//制作
tar    cvf xxx.tar xxx  // 这样创建 xxx.tar 文件先
xz    xxx.tar  //将 xxx.tar 压缩成为 xxx.tar.xz,会删除原来的 tar 包
xz    -k xxx.tar //将 xxx.tar 压缩成为 xxx.tar.xz,保留原来的 tar 包


//解压
xz -d ***.tar.xz //先解压 xz,删除原来的 xz 包
xz -dk ***.tar.xz  // 先解压 xz,保留原来的 xz 包
tar -xvf ***.tar  //再解压 tar

//查看
xz -l ***.tar.xz  //先解压 xz

Guess you like

Origin blog.csdn.net/zhoupenghui168/article/details/133149828