How to Install UNRAR on Ubuntu 22.04 or 20.04

This guide demonstrates how to install UNRAR on Ubuntu 22.04 or 20.04 LTS Linux, primarily focusing on the installation of the UNRAR package directly from Ubuntu’s default repository, while also covering the installation of the unrar-free package.

UNRAR is a powerful tool for extracting files from RAR archives, widely used in the Linux community. Originating as a proprietary software, it has evolved to become an essential utility for users dealing with compressed files. Released initially for Unix-like systems, UNRAR has been continually updated, with its current version set to reach end-of-life on November 12, 2026.

Key Features of UNRAR:

  • Archive Compatibility: Supports various versions of RAR archives, ensuring broad usability.
  • Cross-Platform Functionality: Works seamlessly across different versions of Linux, including Ubuntu 22.04 and 20.04 LTS.
  • Command-Line Interface: Offers a robust CLI for efficient management of archives, especially useful for administrators and developers.
  • Secure Extraction: Ensures the integrity of files during extraction, safeguarding against data corruption.
  • Script Integration: Can be integrated into scripts for automated tasks, enhancing its utility in complex workflows.

Transitioning smoothly into the technical aspects, let’s delve into the specifics of installing UNRAR on Ubuntu Linux. The process is straightforward, involving a few commands and adherence to standard Linux installation practices. Whether you’re a casual user, system administrator, or developer, mastering this installation will streamline your workflow when handling RAR files.

Install UNRAR on Ubuntu 22.04 or 20.04

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. Execute the following command in the terminal:

sudo apt update && sudo apt upgrade

Install UNRAR on Ubuntu 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:

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

Remember that unrar-free may not fully meet your needs if you frequently work with newer RAR formats. Also, note that the commands for unrar-free differ from those for the standard UNRAR package.

Basic UNRAR Commands for Ubuntu 22.04 or 20.04

Extracting Files Without Preserving Paths

To extract files from a RAR archive without keeping the original directory structure, use:

unrar e archive.rar

Replace archive.rar with your RAR file’s name. This command extracts files directly to the current directory.

Listing Archive Contents

To view the contents of a RAR archive, use:

unrar l archive.rar

Replace archive.rar with your archive’s name. This command shows a list of files in the archive.

Printing File to Standard Output

For displaying the contents of a specific file within a RAR archive, use:

unrar p archive.rar file.txt

Replace archive.rar with your RAR file’s name and file.txt with the file you wish to view.

Testing Archive for Errors

To check a RAR archive for any errors or corruption, use:

unrar t archive.rar

Replace archive.rar with the archive you want to test. This ensures the integrity of the archive.

Verbosely Listing Archive Contents

For a detailed list of the contents of a RAR archive, including file sizes and compression info, use:

unrar v archive.rar

Replace archive.rar with your archive’s name. This provides comprehensive details about the files.

Extracting Files with Full Path

To extract files while preserving the full directory structure, use:

unrar x archive.rar

Replace archive.rar with your RAR file’s name. This command maintains the original folder layout.

Extracting With Password

For extracting files from a password-protected RAR archive, use:

unrar x -ppassword archive.rar

Replace archive.rar with your file’s name and password with the actual password.

Excluding Specific Files During Extraction

To exclude a particular file while extracting, use:

unrar x -xfile_to_exclude.txt archive.rar

Replace archive.rar with your RAR file’s name and file_to_exclude.txt with the file you don’t want to extract.

Updating Files in an Archive

To update files within a RAR archive, use:

unrar u archive.rar

Replace archive.rar with your RAR file’s name. It updates only files older than those in the archive.

Setting Output Path for Extracted Files

To extract files to a specific location, use:

unrar x -op/destination/path/ archive.rar

Replace archive.rar with your file’s name and /destination/path/ with your desired extraction path.

See also
How to Install Python 3.12 on Ubuntu 22.04 or 20.04

Conclusion

That wraps up our guide on installing and using UNRAR on Ubuntu 22.04 or 20.04. We’ve walked through updating your system, installing UNRAR, and covered a range of essential commands to manage your RAR files effectively. Remember, choosing between UNRAR and unrar-free depends on your needs for RAR format compatibility. For everyday tasks, UNRAR is a reliable choice, offering robust features and straightforward usability. Keep experimenting with the commands we explored to become more proficient. Happy uncompressing!

Leave a Comment


TOC Index
Your Mastodon Instance
Share to...