UNRAR provides a command-line utility for extracting RAR archives on Ubuntu, handling everything from simple downloads to password-protected multi-volume backups. Whether you need to extract software packages, game mods, or archived project files, UNRAR processes these archives directly from the terminal without requiring a graphical application.
This guide covers installing both the proprietary unrar package and the open-source unrar-free alternative, demonstrates essential extraction commands with practical examples, and shows how to handle password-protected archives and selective file extraction. You will also learn which package to choose based on your archive compatibility needs.
Choose Your UNRAR Package
Ubuntu offers two packages for extracting RAR archives, each with different capabilities and licensing. Understanding these differences upfront helps you choose the right tool for your needs.
| Feature | unrar (Proprietary) | unrar-free (GPL) |
|---|---|---|
| RAR5 format support | Yes | No |
| RAR4 format support | Yes | No |
| RAR3 format support | Yes | Yes |
| Password-protected archives | Yes | Yes |
| Multi-volume archives (.part1.rar) | Yes | No |
| Repository | multiverse | universe |
| License | Proprietary (RARLAB) | GPL (open-source) |
For most users, install unrar because it supports all RAR format versions. Most RAR files downloaded from the internet use RAR5 compression, which unrar-free cannot extract. Only choose unrar-free if you specifically require open-source licensing and only work with older RAR3 archives.
These steps cover Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS. The commands are identical across all supported LTS releases, though package version numbers differ. In all examples throughout this guide, replace
archive.rarwith your actual archive filename and/destination/path/with your preferred extraction location.
Update Ubuntu Before Installing UNRAR
Before installing new packages, update your system’s package index to ensure you receive the latest available versions. Open a terminal from the applications menu or search for “Terminal” in your desktop environment, then run:
sudo apt update && sudo apt upgrade
This command refreshes the package lists and upgrades any outdated packages, preparing your system for a clean installation.
Install UNRAR with APT
The proprietary unrar package from RARLAB provides full compatibility with all RAR archive versions and is the recommended choice for most users. Install it with:
sudo apt install unrar
The
unrarpackage is located in Ubuntu’s multiverse repository, which contains software that is not free or has licensing restrictions. On standard Ubuntu desktop installations, multiverse is enabled by default. If you receive a “package not found” error, enable multiverse withsudo add-apt-repository multiverse && sudo apt updateand retry the installation.
After installation completes, verify that UNRAR is accessible by checking its version:
unrar
Running unrar without arguments displays the version and usage information. Expected output on Ubuntu 26.04 LTS:
UNRAR 7.20 beta 3 freeware Copyright (c) 1993-2025 Alexander Roshal
Usage: unrar <command> -<switch 1> -<switch N> <archive> <files...>
<@listfiles...> <path_to_extract/>
<Commands>
e Extract files without archived paths
l[t[a],b] List archive contents [technical[all], bare]
p Print file to stdout
t Test archive files
v[t[a],b] Verbosely list archive contents [technical[all],bare]
x Extract files with full path
Version numbers differ across Ubuntu releases: Ubuntu 24.04 LTS includes UNRAR 7.00, while Ubuntu 22.04 LTS includes UNRAR 6.11. All versions support the same core extraction commands documented in this guide.
Alternative: Install unrar-free (Open-Source)
If you require an open-source alternative and only work with older RAR3 archives, install unrar-free instead:
sudo apt install unrar-free
This package is located in the universe repository, which is enabled by default on all Ubuntu installations. After installation, verify with:
unrar-free --version
The
unrar-freepackage only supports RAR3 archives. If you encounter “Unsupported format” or extraction errors with modern RAR files, switch to the proprietaryunrarpackage instead. Additionally, command syntax differs between the two packages:unrar-freeuses GNU-style options (-t,--extract) whileunraruses single-letter commands (x,l,t).
For working with other archive formats, see the unzip command guide for ZIP files, the tar and gzip guide for compressed tarballs, or 7-Zip on Ubuntu for a universal archive manager supporting multiple formats including RAR, ZIP, and 7z.
UNRAR Command Examples
The following examples demonstrate the proprietary unrar package, which most users will install. If you installed unrar-free instead, see the separate section below for its GNU-style command syntax.
List Archive Contents Before Extracting
Before extracting files, inspect the archive contents to verify what you’re working with and check the directory structure:
unrar l archive.rar
This command displays a list of all files in the archive along with their sizes and modification dates, helping you understand the directory structure before extraction.
Extract Files with Full Directory Structure
For most use cases, extract files while preserving the original directory structure. This is the recommended extraction method:
unrar x archive.rar
The x command maintains the original folder layout, which prevents files from different directories with identical names from overwriting each other. Files extract to the current working directory by default.
Extract Files Without Directory Structure
When you need all files in a single location regardless of their original paths, use the extract-without-paths command:
unrar e archive.rar
The e command extracts files directly to the current directory, flattening the entire structure. Use this carefully because files with identical names from different directories will overwrite each other without warning.
Extract to a Specific Directory
Direct extraction output to a specific location instead of the current directory by specifying the destination path after the archive name:
unrar x archive.rar /destination/path/
The destination directory will be created automatically if it doesn’t exist. Include the trailing slash to indicate a directory path.
Test Archive Integrity
Verify archive integrity before extraction to detect corrupted or incomplete files, especially useful for large downloads:
unrar t archive.rar
The t command checks for errors or corruption without extracting files, confirming the archive downloaded completely and remains intact. If any file fails the integrity check, the output will indicate which files are corrupt.
Extract Password-Protected Archives
Handle password-protected RAR archives by providing credentials during extraction. For security, omit the password from the command line so UNRAR prompts you interactively:
unrar x archive.rar
When UNRAR detects a password-protected archive, it will prompt: Enter password (will not be echoed):. This approach keeps your password out of shell history.
Alternatively, if you need to script extraction or prefer inline entry, use the -p switch with no space between the flag and password:
unrar x -pYourPassword archive.rar
Passwords passed on the command line are visible in process listings and shell history. For security-sensitive archives, always use the interactive prompt or clear your shell history afterward with
history -c.
View Detailed Archive Information
Display comprehensive archive details including file sizes, compression ratios, and timestamps with the verbose listing command:
unrar v archive.rar
This verbose listing shows compression methods, original sizes, packed sizes, and modification dates for every file, which helps you understand how much space extraction will require.
Exclude Specific Files During Extraction
Extract archives while skipping unwanted files or patterns using the -x switch:
unrar x -x*.tmp -x*.log archive.rar
Use multiple -x flags to exclude different patterns. This example skips all .tmp and .log files. Wildcards work with both filenames and paths, so -x*debug* would exclude any file containing “debug” in its name.
Preview File Contents Without Extraction
Display a specific file’s contents directly to your terminal without extracting the archive:
unrar p archive.rar file.txt
The p command prints the file to standard output, which is useful for quickly checking text files, configuration files, or README documents before deciding whether to extract the full archive.
unrar-free Command Reference
If you installed unrar-free instead of the proprietary package, use these GNU-style commands. Note that unrar-free only supports RAR3 archives, so if you encounter format errors with modern RAR files, you must switch to the proprietary unrar package.
The following table shows how common tasks translate between the two packages:
| Task | unrar (proprietary) | unrar-free |
|---|---|---|
| List contents | unrar l archive.rar | unrar-free -t archive.rar |
| Extract with paths | unrar x archive.rar | unrar-free -x archive.rar |
| Extract flat | unrar e archive.rar | unrar-free --extract-no-paths archive.rar |
| Test integrity | unrar t archive.rar | Not available |
| Password prompt | unrar x archive.rar (prompts automatically) | unrar-free -p archive.rar |
| Verbose listing | unrar v archive.rar | Not available |
# List archive contents
unrar-free -t archive.rar
# Extract files (default behavior)
unrar-free -x archive.rar
# Extract to a specific directory
unrar-free -x archive.rar /destination/path/
# Extract without preserving directory structure
unrar-free --extract-no-paths archive.rar
# Extract password-protected archive (prompts for password)
unrar-free -p archive.rar
The command syntax uses short flags (-t, -x, -p) or their long equivalents (--list, --extract, --password). On Ubuntu 26.04 LTS, unrar-free version 0.3.3 also includes -P (--print) for displaying file contents to stdout, but this option is not available on Ubuntu 24.04 or 22.04.
Troubleshooting Common Issues
Unsupported Format or Extraction Errors
If you encounter errors like “Unsupported archive format” or “Unknown archive type” when using unrar-free, the archive likely uses RAR4 or RAR5 compression. Switch to the proprietary package:
sudo apt remove unrar-free
sudo apt install unrar
After switching packages, retry the extraction with the same archive file.
Package Not Found Error
If apt install unrar returns “E: Unable to locate package unrar”, the multiverse repository is not enabled. Enable it and refresh the package lists:
sudo add-apt-repository multiverse
sudo apt update
sudo apt install unrar
Corrupted or Incomplete Archives
If extraction fails partway through or reports CRC errors, test the archive integrity first:
unrar t archive.rar
If the test reports failures, the archive is damaged. Re-download the file if possible or check whether the source provides repair volumes (.rev files) that can reconstruct missing data.
Multi-Volume Archive Errors
Multi-volume archives (split into .part1.rar, .part2.rar, etc.) require all parts to be present in the same directory. Point UNRAR at the first part:
unrar x archive.part1.rar
UNRAR automatically locates and processes subsequent parts. If any part is missing, extraction will fail with an error indicating which volume cannot be found. Multi-volume extraction is not supported by unrar-free.
Remove UNRAR from Ubuntu
If you no longer need RAR extraction capabilities, remove the package and its unused dependencies.
Remove the Proprietary unrar Package
sudo apt remove unrar
sudo apt autoremove
Remove the unrar-free Package
sudo apt remove unrar-free
sudo apt autoremove
The autoremove command cleans up any libraries that were installed as dependencies and are no longer required by other packages.
Conclusion
UNRAR provides reliable RAR extraction on Ubuntu through the proprietary package with full RAR5 support or the open-source unrar-free alternative for legacy RAR3 files. With the x command preserving directory structures, the t command verifying archive integrity, and the -p switch handling password protection, your Ubuntu system can now extract RAR archives for software packages, game mods, compressed backups, and any other RAR-compressed content you encounter.