在 Linux 解压 RAR 和 7z 压缩包

在终端用 7-Zip 打开 .rar 和 .7z 文件。

Linux压缩与归档归档低风险
运行 7z x 压缩包.rar -o./输出目录 即可解压到指定文件夹。

01命令

命令
$ 7z x photos.rar -o./photos && 7z x backup.7z

02作用说明

p7zip-full 提供的 7z 支持几十种压缩格式,包括 RAR(较老的 RAR 格式)和它自家的 7z。x 参数会按压缩包内的目录结构完整解压,-o 指定解压到哪个文件夹。如果遇到 RAR5 新格式报错,安装 unrar 包后改用 unrar x 文件.rar 即可。

03风险

风险低风险
使用条件p7zip-full (7z); for RAR5 archives also install the non-free `unrar` package and run `unrar x photos.rar`
!注意: 解压时会直接覆盖目标目录里的同名文件而不询问。建议解压到新建目录(-o./某目录),不要直接解到下载文件夹里。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • 7z(1) — 7-Zip file archiver
    manpages.ubuntu.com · community · 2026-09-17
    依据: 7z x extracts archives with full paths; -o sets the output directory and supports 7z, rar, zip and many other formats.

最后验证: 2026-09-18 · 分类: 文件与文件夹

06相关方案