RAR archives can contain whole directory trees. unrar extracts RAR archives into a chosen directory while preserving their stored paths.

RARLAB's unrar can list an archive's contents and test its data without writing extracted files. A successful integrity test confirms that the data can be read, including any password-protected files and split volumes.

Unfamiliar archives can contain unwanted files, so extraction belongs in a dedicated destination directory under your normal user account. An archive distributed as several volumes needs the complete set in one directory before extraction can finish.

Steps to extract RAR files in Linux:

  1. Install RARLAB's unrar if it is not already available.
    $ sudo apt install unrar

    On Ubuntu, the unrar package is supplied by multiverse; on Debian, it is supplied by non-free. The APT command applies to these distributions with that component enabled and an up-to-date package index. If the package is unavailable, check the distribution's repository configuration.
    Ubuntu package management ยท Debian archive components

  2. Check the archive type before extraction.
    $ file testfile.rar5.rar
    testfile.rar5.rar: RAR archive data, v5

    When the archive is split across volumes, run the listing, test, and extraction commands against the first volume such as project.part1.rar or project.part01.rar.

  3. List the archive contents without writing files.
    $ unrar l testfile.rar5.rar
    UNRAR 7.12 freeware      Copyright (c) 1993-2025 Alexander Roshal
    
    Archive: testfile.rar5.rar
    Details: RAR 5
    
     Attributes      Size     Date    Time   Name
    ----------- ---------  ---------- -----  ----
     -rw-rw-rw-        12  2001-01-01 05:00  testfile.txt
    ----------- ---------  ---------- -----  ----
                       12                    1

    The l action confirms file names, sizes, and the stored directory layout before anything is unpacked.

  4. Test the archive data before extraction.
    $ unrar t testfile.rar5.rar
    ##### snipped #####
    Testing archive testfile.rar5.rar
    ##### snipped #####
    All OK

    Encrypted archives prompt for a password during t or x when unrar needs to read the protected file data. If a password is requested, enter it at the prompt rather than putting it in the command line.

    Do not extract unless the test finishes with All OK. If the test reports a wrong password, damaged data, or a missing split volume, stop before extraction. Do not continue until the password is corrected or the complete, undamaged archive is available and a repeated test finishes with All OK.

  5. Create a dedicated target directory.
    $ mkdir -p extracted

    A clean directory keeps restored files separate from unrelated data. If extracted already contains files, choose a different empty destination; -o- skips existing names rather than replacing them.

  6. Extract the archive into the target directory.
    $ unrar x -o- testfile.rar5.rar extracted/
    ##### snipped #####
    Extracting from testfile.rar5.rar
    ##### snipped #####
    All OK

    The x action keeps archived directories. Use e only when the stored directory structure should be discarded.

  7. Verify that the expected files were written to the destination directory.
    $ find extracted -type f
    extracted/testfile.txt

    The listed files should match the archive contents, including any nested directories. -o- leaves existing files untouched, so an extraction that skipped files does not prove that every archived file was restored.

Share this guide