Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Extract RAR Files on Linux: 5 Easy Ways

· 6 min read · Home Tech

In this article
  1. Why Linux Can't Open RAR Files Natively
  2. Installing RAR Extraction Tools
  3. Using the unrar Command
  4. Using 7-Zip (p7zip) as an Alternative
  5. Using unar (The Unarchiver) for Simplicity
  6. Common Problems and Solutions
  7. Graphical Extraction in File Managers
  8. Security and Safety Considerations
  9. Frequently Asked Questions

To extract RAR files on Linux, you need to install a utility called unrar (or use alternatives like 7z or unar), because Linux does not handle RAR archives by default. The most common command is unrar x file.rar, which extracts the archive into the current directory. Below is a detailed guide covering installation, usage, troubleshooting, and alternatives.

Why Linux Can't Open RAR Files Natively

RAR is a proprietary archive format created by Eugene Roshal. Unlike ZIP, which has broad built-in support in every operating system, RAR compression and decompression are controlled by the WinRAR software and its command-line tools. Linux distributions do not include RAR support out of the box because the format is not open-source and the decompression tools are distributed under a restrictive license.

Most Linux users encounter RAR files when downloading content from Windows-centric sites or receiving archives from colleagues. The good news is that free, open-source tools like p7zip and unar can read RAR files without any licensing issues, while the official unrar utility is free to use for extracting (though not for creating archives).

Installing RAR Extraction Tools

You have several options, depending on your distribution and whether you want the official tool or an open-source alternative.

  • Debian/Ubuntu: sudo apt install unrar (official) or sudo apt install p7zip-full (open-source).
  • Fedora/RHEL: sudo dnf install unrar (requires RPM Fusion repo) or sudo dnf install p7zip.
  • Arch Linux: sudo pacman -S unrar (official) or sudo pacman -S p7zip.
  • openSUSE: sudo zypper install unrar or sudo zypper install p7zip.
  • macOS (via Homebrew): brew install unrar or brew install p7zip.

If you prefer a graphical interface, most desktop environments (GNOME Files, Dolphin, Nautilus) will automatically use whichever command-line tool is installed when you right-click and select "Extract Here".

Using the unrar Command

The official unrar utility is the most reliable for RAR files. Here are the essential commands:

  1. Extract to current directory: unrar x archive.rar
  2. Extract to a specific directory: unrar x archive.rar /path/to/destination/
  3. List contents without extracting: unrar l archive.rar
  4. Test archive integrity: unrar t archive.rar
  5. Extract with full paths (default): unrar e archive.rar extracts files without directory structure (flat).

The x option preserves the folder structure, while e dumps all files into one directory. If the archive is password-protected, unrar will prompt you; you can also provide the password with -p (e.g., unrar x -psecret archive.rar).

Using 7-Zip (p7zip) as an Alternative

The 7z command from the p7zip package is a versatile tool that handles RAR, ZIP, 7z, and many other formats. It is open-source and often pre-installed on minimal systems. To extract a RAR file:

7z x archive.rar

This will extract all files into the current directory, preserving paths. To extract to a specific folder:

7z x archive.rar -o/path/to/output

Note that the -o flag must have no space between it and the directory path. To list contents: 7z l archive.rar. To test: 7z t archive.rar.

One limitation: older versions of p7zip may not support RAR5 (the newer RAR format). If you get a "Unsupported Method" error, install the official unrar or update p7zip to version 16.02 or later.

Using unar (The Unarchiver) for Simplicity

unar is a command-line tool derived from The Unarchiver, popular on macOS. It automatically detects the archive format and handles RAR, ZIP, 7z, and many others without needing flags. Install it on Debian/Ubuntu with sudo apt install unar. To extract:

unar archive.rar

It creates a folder named after the archive in the current directory. It also handles password-protected archives by prompting. For a list of options, run unar -h.

Common Problems and Solutions

Here are typical issues you might face and how to fix them:

  • "command not found" – The tool isn't installed. Run the appropriate install command for your distribution.
  • "Unsupported Method" – The archive uses RAR5 compression, and your 7z is too old. Install unrar or update p7zip.
  • "CRC Failed" – The archive is corrupted. Re-download it, or try unrar t to identify which file is bad.
  • Password prompt but you don't know the password – You cannot bypass it; RAR encryption is strong. Contact the sender.
  • Extracted files have no permissions – Some archives store Unix permissions. Use unrar x (not e) to preserve them.
  • Multi-volume archives (file.part1.rar) – Extract only the first part; the tool will automatically find the rest. Ensure all parts are in the same directory.

Graphical Extraction in File Managers

If you prefer a GUI, most Linux file managers integrate with archive tools via the file-roller (GNOME), ark (KDE), or engrampa (MATE). Once you install unrar or p7zip, right-clicking a RAR file will show "Extract Here" or "Extract To...". For example, in Nautilus (GNOME Files), right-click → "Extract" will use the installed backend automatically.

If the GUI doesn't work, open a terminal and run the command manually – that will give you the exact error message.

Security and Safety Considerations

RAR files can contain executable code, so always extract with caution, especially if the archive came from an untrusted source. Before extracting, run unrar l archive.rar to view the contents. Be wary of archives that contain scripts or binaries you weren't expecting. Also, avoid extracting as root; use a normal user account to minimize potential damage from a malicious file.

Additionally, RAR files can be encrypted with strong AES-256. There is no legitimate way to recover a forgotten password, so keep passwords safe. If you receive a password-protected RAR from a legitimate source, the password is usually provided separately.

Frequently Asked Questions

How do I extract a RAR file in a specific directory?

Use unrar x archive.rar /path/to/destination/ (note the trailing slash). For 7z, use 7z x archive.rar -o/path/to/destination (no space after -o). If the destination doesn't exist, the tool will create it.

Can I extract RAR files without installing anything?

No. Linux has no built-in RAR support. You must install at least one tool. However, if you have a web browser, you can use online extraction services, but uploading sensitive files to third-party sites is not recommended for security reasons.

What is the difference between RAR and RAR5?

RAR5 is a newer version of the format introduced with WinRAR 5.0. It offers better compression and improved error recovery. Older tools (like p7zip versions before 16.02) cannot read RAR5. The official unrar supports both.

Why does unrar ask for a password even though I know the archive isn't encrypted?

That usually means the archive has a header encryption flag, which hides even the file list. If you don't have the password, you can't proceed. Double-check with the sender; sometimes the password is blank (just press Enter).

Can I create RAR files on Linux?

Yes, but the official rar command is proprietary and not free. You can install it via sudo apt install rar on Debian/Ubuntu. Alternatively, use 7z to create 7z or ZIP archives, which are more open and widely supported.

How do I extract a multi-volume RAR file?

Place all parts (e.g., file.part1.rar, file.part2.rar) in the same directory. Then extract only the first part: unrar x file.part1.rar or 7z x file.part1.rar. The tool automatically reads the subsequent parts.