Home·Terminal commands

rar

Archives

Usage

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

A proprietary format where only the extractor is free: creating an archive needs the paid rar binary, while `unrar x` — or `7z x` with nothing installed from RARLAB — unpacks one someone sent you, `x` keeping the stored paths and `e` flattening them, `-hp` hiding the file names too and `-v100m` splitting the archive into volumes.

Common flags

FlagMeaning
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.

Examples

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.

Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does rar do?

A proprietary format where only the extractor is free: creating an archive needs the paid rar binary, while `unrar x` — or `7z x` with nothing installed from RARLAB — unpacks one someone sent you, `x` keeping the stored paths and `e` flattening them, `-hp` hiding the file names too and `-v100m` splitting the archive into volumes.

Q. How do I type it?

rar a <archive.rar> <files> | unrar x <archive.rar> — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

7 are listed here; the full set is in man rar. This command sits under Archives.

Related commands

man page: man rar