Can unrar Create RAR Archives?
The short answer is no: the unrar command-line utility
cannot create archives because it is strictly designed for listing,
testing, and extracting existing RAR files. To create RAR archives, you
must use the separate, proprietary rar command-line tool or
a graphic frontend like WinRAR.
Why unrar Cannot Create Archives
The limitation stems from licensing and the proprietary nature of the RAR format. While the author of the format, Eugene Roshal, released the source code for RAR decompression to the public for free use, the compression algorithm remains proprietary.
As a result, software packages distribute two distinct tools:
- unrar: A dedicated utility built exclusively to
decompress, view, and extract
.rararchives. - rar: The full utility that supports both creating (compressing) and managing RAR archives.
How to Create RAR Archives on the Command Line
If you need to generate a .rar file from the
terminal—particularly on Linux or macOS—you must install the full
rar package instead of unrar.
Once installed, use the a (add) command to build an
archive:
rar a archive_name.rar file1.txt file2.txt /path/to/folderCommon flags for archive creation include:
-r: Recurse into subdirectories.-m5: Set compression to maximum.-p: Password-protect the archive with encryption.
Open Alternatives to RAR Compression
Because creating RAR files requires proprietary shareware, modern workflows often favor open compression formats supported natively by most systems.
If you do not strictly require the .rar extension,
consider these alternatives:
- 7-Zip (
7z): Offers higher compression ratios than standard RAR, supports strong AES-256 encryption, and is fully open-source. Command:7z a archive.7z files... - Tar with Gzip or XZ (
tar): The standard Unix utility for creating compressed bundles. Command:tar -czvf archive.tar.gz files... - Zip (
zip): Universally supported across Windows, macOS, and Linux without third-party tools. Command:zip -r archive.zip files...