rar Command
The rar command is the command-line interface for the WinRAR archiver on Linux and Unix-like systems. It allows you to create, extract, list, and manage .rar archives. While .rar is a proprietary format, the rar and unrar tools are widely available for handling these files.
Syntax
unrar <command> [ -switch1 -switch2 ... ] <archive> [ <files...> ] [ <path_to_extract...> ]
Description
The rar utility provides a comprehensive set of features for working with RAR archives, including solid archiving, encryption, and recovery records. The unrar utility is specifically for extracting files from RAR archives.
Common uses include:
- Creating new
.rararchives. - Extracting files from
.rararchives. - Listing the contents of a
.rararchive. - Creating password-protected archives.
Common Commands and Switches
| Command/Switch | Description |
|---|---|
a |
Add files to archive. |
x |
Extract files with full paths. |
e |
Extract files to current directory (without paths). |
l |
List contents of archive. |
d |
Delete files from archive. |
-p<password> |
Set password for archive. |
-v |
Verbose mode (list files while processing). |
-r |
Recurse subdirectories. |
Examples
Create a RAR archive
Creates myarchive.rar containing file1.txt and the folder/ directory.
Extract a RAR archive with full paths
Extracts all files from myarchive.rar, preserving their original directory structure.
Extract a RAR archive to current directory (without paths)
Extracts all files from myarchive.rar directly into the current working directory.
List contents of a RAR archive
Lists all files and folders within myarchive.rar without extracting them.
Create a password-protected RAR archive
Creates a password-protected archive named secret.rar.