首页·终端命令

rar

压缩与传输

用法

rar a <archive.rar> <files> | unrar x <archive.rar>

这是私有格式,免费的只有解包那一头:要新建得用付费的 rar,而别人发来的 .rar 用 `unrar x` 就能解开,或者干脆 `7z x`,不必从 RARLAB 装任何东西;`x` 保留包里记的路径,`e` 把它们摊平,`-hp` 连文件名一起藏,`-v100m` 切成多卷。

常用选项

选项含义
aAdd or create an archive (rar only).
xExtract with full paths; e flattens them. Both work in unrar.
lList the contents.
-p<password>Encrypt the contents. Use -hp instead, not as well, to encrypt the file names too.
-m5Maximum compression.
-rRecurse into subdirectories.
-v100mSplit into 100 MB volumes.

示例

unrar x archive.rar

Extract a .rar someone sent you, keeping its folders.

7z x archive.rar

Extracts without RARLAB tools; on many Linux distros this needs the non-free p7zip-rar codec.

rar a -m5 -r backup.rar ./data

Create a .rar, which needs the paid rar binary.

打包和压缩是两件事:tar 打包,gzip 压小,.tar.gz 是两样一起。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. rar 是做什么的?

这是私有格式,免费的只有解包那一头:要新建得用付费的 rar,而别人发来的 .rar 用 `unrar x` 就能解开,或者干脆 `7z x`,不必从 RARLAB 装任何东西;`x` 保留包里记的路径,`e` 把它们摊平,`-hp` 连文件名一起藏,`-v100m` 切成多卷。

Q. 怎么写?

rar a <archive.rar> <files> | unrar x <archive.rar> —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 7 个,完整列表在 man rar。这条命令属于压缩与传输。

相关命令

man 手册: man rar