How to Install UNRAR on Ubuntu Linux

UNRAR provides a reliable command-line utility for extracting RAR archives on Ubuntu, similar to how Windows users handle RAR files with WinRAR or 7-Zip. Ubuntu offers two versions: the proprietary unrar package from RARLAB with full RAR 5 support and advanced features, and the open-source unrar-free alternative with basic extraction capabilities. The proprietary version handles password-protected archives, multi-volume RAR files, and the latest compression formats, while unrar-free covers simpler RAR 3 archives without newer format support.

This guide covers installing both unrar and unrar-free on Ubuntu, demonstrates essential extraction commands with full path preservation, and shows how to handle password-protected archives and selective file extraction. You’ll learn when to choose the proprietary version for maximum compatibility versus the open-source alternative for straightforward extraction tasks.

Update Ubuntu Before Installing UNRAR

To begin, update your Ubuntu system. This step ensures your system has the latest features and security patches, making it ready for new installations. Press Ctrl+Alt+T or search for “Terminal” in the application menu, then run the following command:

sudo apt update && sudo apt upgrade

Install UNRAR via APT Install Command

After updating your system, you can install UNRAR. This utility is essential for extracting RAR files. Use this command to install UNRAR from RARLAB, which is a proprietary version offering full compatibility with various RAR formats. The command uses APT (Advanced Package Tool, Ubuntu’s package manager similar to combining Windows Update and the Microsoft Store) to pull the package from Ubuntu’s repositories:

sudo apt install unrar

Alternative: Installing UNRAR-Free

If you prefer an open-source alternative, consider installing unrar-free. This version, however, has limitations, such as lacking support for RAR 4 or 5 formats. To install unrar-free, use this command:

sudo apt install unrar-free

The unrar-free package lacks support for RAR 4 and RAR 5 formats, which most modern RAR archives use. If you encounter extraction errors or “unsupported format” messages, install the proprietary unrar package instead. Additionally, command syntax differs between unrar and unrar-free, so verify your chosen package before scripting extraction tasks.

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.

Essential UNRAR Commands

List Archive Contents Before Extracting

Before extracting files, inspect the archive contents to verify what you’re working with:

unrar l archive.rar

Replace archive.rar with your archive’s name. This command shows a list of files in the archive, 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:

unrar x archive.rar

Replace archive.rar with your RAR file’s name. This command maintains the original folder layout, which prevents files from different directories from overwriting each other.

Extract Files Without Directory Structure

When you need all files in one location regardless of their original paths, use the extract-without-paths command:

unrar e archive.rar

Replace archive.rar with your RAR file’s name. This command extracts files directly to the current directory, flattening the entire structure. Use this carefully, as files with identical names from different directories will overwrite each other.

Extract to Specific Directory

Direct extraction output to a specific location instead of the current directory:

unrar x archive.rar /destination/path/

Replace archive.rar with your file’s name and /destination/path/ with your desired extraction location. The destination directory will be created automatically if it doesn’t exist.

Test Archive Integrity

Verify archive integrity before extraction to avoid corrupted or incomplete files:

unrar t archive.rar

Replace archive.rar with the archive you want to test. This command checks for errors or corruption without extracting files, confirming the archive downloaded completely and remains intact.

Extract Password-Protected Archives

Handle password-protected RAR archives by providing credentials during extraction:

unrar x -pYourPassword archive.rar

Replace archive.rar with your file’s name and YourPassword with the actual password. Note there’s no space between -p and the password. For security, avoid including passwords in shell history by omitting the -p flag entirely so unrar will prompt you interactively.

View Detailed Archive Information

Display comprehensive archive details including file sizes, compression ratios, and timestamps:

unrar v archive.rar

Replace archive.rar with your archive’s name. This verbose listing shows compression methods, original sizes, packed sizes, and modification dates for every file.

Exclude Specific Files During Extraction

Extract archives while skipping unwanted files or patterns:

unrar x -x*.tmp -x*.log archive.rar

Replace archive.rar with your RAR file’s name. Use multiple -x flags to exclude different patterns. This example skips all .tmp and .log files. Wildcards work with both filenames and paths.

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

Replace archive.rar with your RAR file’s name and file.txt with the target file. This prints the file to standard output, useful for quickly checking text files, configuration files, or README documents.

Conclusion

UNRAR delivers reliable RAR extraction capabilities on Ubuntu through two packages: the proprietary unrar with full RAR 5 support and advanced features, or unrar-free for basic open-source extraction. The installation process covers choosing between comprehensive compatibility and open-source principles, using essential extraction commands with path preservation, and handling password-protected or selective file scenarios. Your Ubuntu system now extracts RAR archives efficiently whether working with downloaded software, compressed backups, or multi-volume archives.

Leave a Comment