LinuxCommandLibrary

rar

Create and extract RAR archives

TLDR

Archive 1 or more files

$ rar a [path/to/archive_name.rar] [path/to/file1 path/to/file2 path/to/file3 ...]
copy

Archive a directory
$ rar a [path/to/archive_name.rar] [path/to/directory]
copy

Split the archive into parts of equal size (50M)
$ rar a -v[50M] -R [path/to/archive_name.rar] [path/to/file_or_directory]
copy

Password protect the resulting archive
$ rar a -p[password] [path/to/archive_name.rar] [path/to/file_or_directory]
copy

Encrypt file data and headers with password
$ rar a -hp[password] [path/to/archive_name.rar] [path/to/file_or_directory]
copy

Use a specific compression level (0-5)
$ rar a -m[compression_level] [path/to/archive_name.rar] [path/to/file_or_directory]
copy

SYNOPSIS

rar [options] [files...]

PARAMETERS

a
    Add files to archive.

e
    Extract files without subdirectory names.

x
    Extract files with full pathnames.

l[t,b]
    List archive contents [technical, bare].

t
    Test archive integrity.

d
    Delete files from archive.

f
    Freshen files in archive.

u
    Update files in archive.

k
    Lock archive.

r
    Repair archive.

rc
    Reconstruct missing volumes.

rn
    Rename archive volumes.

-p[password]
    Set password for encryption (use -p without password to be prompted).

-v[k,m,g]
    Create volumes with size .

-m<0-5>
    Set compression level (0=store, 5=best).

-rr[N]
    Add data recovery record (redundancy) with [N] percent.

DESCRIPTION

The RAR program is a command-line tool used for creating, extracting, and managing RAR archives on Linux systems. Unlike many native Linux archive formats, RAR is a proprietary archive format known for its strong compression and recovery record capabilities. It allows for splitting archives into multiple volumes, adding redundancy information for error correction (recovery records), and setting passwords for encryption. While `unrar` is freely available for extraction, `rar` for creation, modification, and repair of archives usually requires a paid license for commercial usage. RAR is suitable for archiving large files, backups, or distributing data. It provides a range of options to customize the archiving process, including compression level, archive type (RAR4 or RAR5), and archive handling. It can update, rename and protect the files.

RAR is not installed by default on most Linux distributions. You might need to install the package 'rar' before using this command.

CAVEATS

RAR is a proprietary format, so full functionality (creation, modification) might require a licensed version, particularly for commercial use. Although `unrar` is generally freely available, `rar` may not be included in the base installation of many Linux distributions and needs to be installed separately.

VOLUME SETS

When creating multi-volume archives, RAR automatically creates a set of files with extensions like .rar, .r00, .r01, etc. These volumes must be stored in the same directory for extraction to work correctly. When extracting, only the first part (.rar) needs to be specified as the archive name.

RETURN CODES

RAR returns specific exit codes upon completion. Understanding these codes can be useful for scripting. For example, 0 indicates successful completion, while other codes may indicate errors.

HISTORY

RAR was developed by Alexander Roshal. The first version of RAR was released in 1993. Over the years, it has evolved to incorporate stronger compression algorithms, encryption methods, and features like recovery records. RAR5, a newer version of the format, introduced some changes to the archive structure that are not fully compatible with older RAR versions. RAR remains a popular archiving tool due to its robust features and cross-platform availability.

SEE ALSO

unrar(1), tar(1), gzip(1), zip(1)

Copied to clipboard