LinuxCommandLibrary

unrar

Extract files from RAR archives

TLDR

Extract files with original directory structure

$ unrar x [compressed.rar]
copy

Extract files to a specified path with the original directory structure
$ unrar x [compressed.rar] [path/to/extract]
copy

Extract files into current directory, losing directory structure in the archive
$ unrar e [compressed.rar]
copy

Test integrity of each file inside the archive file
$ unrar t [compressed.rar]
copy

List files inside the archive file without decompressing it
$ unrar l [compressed.rar]
copy

SYNOPSIS

unrar <command> [<options>] <archive> [<files...>]

PARAMETERS

e
    Extract files to the current directory.

x
    Extract files with full paths.

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

t
    Test archive integrity.

v
    Verbosely list archive contents.

p[password]
    Specify password for encrypted archives.

-y
    Assume 'yes' on all queries.

archive
    The RAR archive file to process.

files...
    Specific files to extract from the archive (optional).

-o[+|-]
    Overwrite mode (+: overwrite all existing files, -: skip existing files)

-ppassword
    Specify password for encrypted archives.

DESCRIPTION

The unrar command is a utility used in Linux to extract files and directories from RAR archives. RAR is a proprietary archive file format, more advanced than tar or zip, that supports data compression, error recovery, and file spanning. unrar allows users to list the contents of RAR files, test the integrity of the archive, and extract its contents to the current directory or a specified location.

It's important to note that unrar is a read-only utility. It can extract and list RAR archives, but it cannot create them. For creating RAR archives, the `rar` command (which may require a separate installation) is used.

Using unrar is straightforward. The basic command structure involves specifying the desired operation (e.g., 'e' for extract, 'l' for list) followed by the name of the RAR archive. The command is a powerful tool for managing and accessing compressed data within RAR archives on Linux systems.

CAVEATS

unrar is a read-only tool. It cannot create RAR archives. For that, the `rar` command (usually requiring separate installation) is needed. Incorrect usage, particularly with wildcards, can lead to unexpected extraction results.

EXIT CODES

unrar returns various exit codes to indicate success or failure. A zero exit code generally indicates successful completion. Non-zero exit codes indicate errors such as invalid arguments, corrupted archives, or missing files. You can check the exit code in shell scripts using the `$?` variable.

FILE PERMISSIONS

When extracting files, unrar attempts to restore the original file permissions stored in the RAR archive. However, due to differences in file system permissions between operating systems, the permissions might not be perfectly preserved. Use caution when extracting archives from untrusted sources, as they may contain executable files with unintended permissions.

HISTORY

The RAR archive format and the associated unrar utility were developed by Alexander Roshal. The format has evolved over time to incorporate improved compression algorithms and features. unrar is widely used on Linux and other platforms for extracting RAR archives, especially those created on Windows systems where RAR is a popular archiving format. The availability of unrar on Linux allows for seamless interoperability between different operating systems when dealing with RAR files.

SEE ALSO

rar(1), gzip(1), zip(1), tar(1)

Copied to clipboard