RAR archives remain common for downloads, backups, and vendor-distributed bundles, so extracting them cleanly on Linux matters when files need to be inspected, staged, or restored without switching to another platform. A predictable extraction flow also reduces the chance of unpacking into the wrong directory or overwriting existing files during shell work and remote sessions.
The unrar command reads archive metadata, lists stored entries, tests archive integrity, and writes the decompressed files into a chosen destination. Using the x action preserves archived path names, which is usually the safest behavior for project folders, software bundles, and split downloads that expect a specific directory layout.
Current Linux distributions do not package RAR readers identically, so package names and fallback commands vary even when the extraction workflow is the same. The steps below assume a working unrar command is already available in the shell and keep extraction in a dedicated target directory so overwrite prompts, password requests, and untrusted archive contents stay easier to control.
Related: How to create a RAR archive in Linux
Related: How to extract 7z files in Linux
Steps to extract RAR files in Linux:
- Change to the directory that contains the .rar file and confirm the archive format before extracting it.
$ cd /tmp/rar-demo $ 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.
- List the archive contents without writing any files to disk.
$ unrar l testfile.rar5.rar UNRAR 7.00 freeware Copyright (c) 1993-2024 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 1The l action is the fastest way to confirm file names, sizes, and the directory layout stored inside the archive before anything is unpacked.
- Test the archive to confirm it can be read cleanly before extraction.
$ unrar t testfile.rar5.rar UNRAR 7.00 freeware Copyright (c) 1993-2024 Alexander Roshal Testing archive testfile.rar5.rar Testing testfile.txt OK All OK
Encrypted archives prompt for a password during t or x when unrar needs to read the protected file data.
- Create a dedicated target directory for the extracted files.
$ mkdir -p extracted
Extracting into a clean directory makes it easier to review the restored files and avoids mixing them with unrelated data already present in the current path.
- Extract the archive into the target directory while preserving any archived paths.
$ unrar x testfile.rar5.rar extracted/ UNRAR 7.00 freeware Copyright (c) 1993-2024 Alexander Roshal Extracting from testfile.rar5.rar Extracting extracted/testfile.txt OK All OK
The x action keeps archived directory paths. Use e only when the directory structure inside the archive should be discarded. Add -o- to refuse overwriting existing files without prompting.
- Verify that the expected files were written to the destination directory.
$ find extracted -maxdepth 2 -print | sort extracted extracted/testfile.txt
A clean directory listing after All OK confirms that the files were restored into the intended target path.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
