tar 打包压缩命令

  1. tar -cf php.tar php-7.2.6 #打包目录不压缩
  2. tar -xf php.tar #解压目录
  3. tar -czvf filename.tar.gz test #打包 test 目录并使用 gzip 压缩并显示文件信息
  4. tar -xzvf filename.tar.gz #解压 gzip 文件并输出文件信息
  5. tar -cjvf filename.tar.bz2 test #打包 test 目录并使用 gzip2 压缩并显示文件信息
  6. tar -xjvf filename.tar.bz2 #解压使用 gzip2 压缩并显示文件信息

补充:-v 为显示信息

zip 压缩命令,文件后缀.zip

  1. zip html.zip ./html #压缩当前目录下 html 目录或文件
  2. unzip html.zip #解压在当前目录或文件
  3. zip -qr html.zip ./html #将当前 html 目录递归压缩保存文件名为 html.zip
  4. unzip html.zip #解压在当前目录
  5. unzip -o html.zip -d /usr/local/ #解压 html.zip 文件到 /usr/local/ 下
  6. zip -qr html.zip ./html #将当前html目录递归压缩为 html.zip

gzip 压缩命令,文件后缀.gz

  1. gzip index.php #压缩 index.php 文件,文件名为 index.php.gz ,不会保留原文件
  2. gunzip index.php.gz #解压文件
  3. gzip -d index.php.gz #解压文件

bzip2 压缩命令,文件后缀.bz2

  1. bzip2 index.php #压缩 index.php 文件,文件名为 index.php.bz2 ,不会保留原文件
  2. bunzip2 index.php.bz2 #解压文件
  3. bzip2 -d index.php.bz2 #解压文件

xz 压缩命令,文件后缀.xz

  1. xz -z index.php #压缩文件
  2. xz -d index.php.xz #解压文件