Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

解压文件 tar/zcat/zip/unzip

  • tar 解压包(即tap archieve)

    • 压缩
      tar -cvf certs.tar ./certs    
      
      • -c是 compress 的意思
    • 解压
      tar -xvf certs.tar ./certs
      
      • -x是 extract 的意思
      • 常用于把开源软件包解压到当前目录下
  • zcat 查看压缩的gz日志

    • 会全部输出,造成卡顿,慎用
  • zip/unzip 压缩/解压

    • 是windows系统上PKZIP工具的Unix实现,使用并没有tar使用广泛

    • 需要安装

      yum install -y unzip zip
      
      apt install -y unzip zip
      
    • zip 压缩

      • zip -q -r html.zip /home/html
        • 把 html目录下 所有文件,打包成html.zip
        • 如果已经在html目录下,那可简化成zip -q -r html.zip *
        • -q表示不显示指令执行过程
        • -r表示对子目录递归处理
      • zip -q -r abc.zip ab c.txt
        • 把目录下的 ab文件夹 和 c.txt文件 压缩到 abc.zip中
    • unzip 解压

      • unzip html.zip 直接解压到当前目录下
      • unzip html.zip -d /home/out_html 解压到 out_html目录里面
      • unzip -l html.zip 只显示里面包含的文件(但不解压)