Linux常用指令(四)——压缩/解压缩工具

Linux压缩/解压缩工具

      • [4.1 zip压缩文件](#4.1 zip压缩文件)
      • [4.2 unzip解压缩文件](#4.2 unzip解压缩文件)
      • [4.3 tar压缩](#4.3 tar压缩)
      • [4.4 tar解压](#4.4 tar解压)

更加完整的Linux常用指令

压缩包文件格式

Windows: *.zip*.7z

Linux: *.zip*.7z**.rar*.gz*.xz*.bz2*.tar等等

4.1 zip压缩文件

bash 复制代码
# 使用zip打包文件夹test
# -r为递归打包包含子目录的全部内容,-q为安静模式,-o表示输出文件
cd /home/test
zip -r -q -o test.zip /home/mydir

# -e参数加密压缩
zip -r -e -o test.zip /home/mydir

4.2 unzip解压缩文件

bash 复制代码
# 解压到当前目录
unzip test.zip

# -q安静模式,解压到指定目录
unzip -q test.zip -d mydir

# 不解压只查看压缩包的内容
unzip -l test.zip

# 解压中文压缩包
unzip -O GBK 中文压缩文件.zip

4.3 tar压缩

bash 复制代码
# 打包test文件
# -P:保留绝对路径
# -c:创建一个tar包
# -f:指定创建文件名
cd /home/test
tar -P -cf test.tar /home/mydir

4.4 tar解压

bash 复制代码
# 解包一个文件(-x参数)到指定路径的已存在目录(-C参数)
mkdir mydir
tar -xf test.tar -C mydir

# -t参数,只查看不解包
tar -tf test.tar

# 解压*.tar.gz文件,-z参数
tar -xzf test.tar.gz
相关推荐
Sokach10156 小时前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
SelectDB21 小时前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao21 小时前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
A小辣椒4 天前
TShark:基础知识
linux
AlfredZhao4 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao5 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi