LinuxTutorialsUbuntu

How To Install Rar/Unrar Packages on Ubuntu

Install Rar/Unrar Packages on Ubuntu

In this tutorial, we will show you how to install Rar/Unrar packages on your Ubuntu. Working with compressed files is an essential part of Linux system administration and daily computing tasks. While Ubuntu comes with excellent built-in support for various archive formats like ZIP, TAR, and GZIP, it notably lacks native support for RAR files. This comprehensive guide will walk you through multiple methods to install RAR and UNRAR packages on Ubuntu, ensuring you can both extract and create RAR archives with ease.

RAR files remain one of the most popular compression formats due to their superior compression ratios and advanced features like password protection and file splitting. Whether you’re a system administrator handling archived data, a developer working with compressed source code, or a regular user dealing with downloaded files, understanding how to properly install and use RAR tools on Ubuntu is crucial for effective file management.

Understanding RAR Files and Ubuntu Compatibility

RAR (Roshal Archive) is a proprietary archive file format developed by Eugene Roshal. Unlike open-source compression formats, RAR offers several advantages including better compression ratios, advanced error recovery, and robust password protection mechanisms. The format supports file spanning across multiple volumes, making it ideal for distributing large files across multiple storage devices.

Ubuntu’s default archive manager doesn’t support RAR files because the format is proprietary and requires specific licensing agreements. The operating system prioritizes open-source alternatives, which is why you can work with ZIP, TAR, and other free formats out of the box. However, this limitation means that Ubuntu users cannot extract RAR files without installing additional software.

The distinction between extracting and creating RAR files is important to understand. While UNRAR is freely available for extracting RAR archives, the RAR creation tool is shareware that requires a license for commercial use after a 40-day trial period. For most users, installing the UNRAR package is sufficient for everyday needs.

Prerequisites and System Preparation

Before installing RAR/UNRAR packages, ensure your Ubuntu system is properly prepared. Start by updating your package lists and upgrading existing packages to their latest versions. This step prevents potential conflicts and ensures compatibility with the latest software repositories.

Execute the following commands in your terminal:

sudo apt update && sudo apt upgrade

This command combination updates the package database and upgrades all installed packages. The update process may take several minutes depending on your internet connection and the number of packages requiring updates.

Verify that your system has the multiverse repository enabled, as some RAR packages are distributed through this repository. Most modern Ubuntu installations include multiverse by default, but you can confirm its availability by checking your sources list or attempting to install packages from this repository.

Method 1: Installing UNRAR via APT Package Manager

The most straightforward approach for installing UNRAR on Ubuntu involves using the APT package manager. This method provides access to the official RARLAB UNRAR package, which offers full compatibility with various RAR formats and versions.

Standard UNRAR Installation

Install UNRAR using the following command:

sudo apt install unrar

This command downloads and installs the proprietary UNRAR package from RARLAB. The installation process typically completes within a few minutes, depending on your internet connection speed. The system will prompt you to confirm the installation by pressing ‘Y’ when asked for permission.

After installation, verify that UNRAR is properly installed by checking the version:

unrar -v

This command displays version information and confirms that the installation was successful. You should see output indicating the UNRAR version number and copyright information.

Test the basic functionality by attempting to list the contents of a RAR file or using the help command:

unrar --help

Alternative: UNRAR-Free Installation

For users preferring open-source alternatives, Ubuntu provides the unrar-free package. However, this version has significant limitations compared to the standard UNRAR package.

Install unrar-free using:

sudo apt install unrar-free

The unrar-free package lacks support for RAR 4 and RAR 5 formats, which means it cannot handle many modern RAR archives. This limitation makes it unsuitable for users who frequently encounter newer RAR files. Additionally, the command syntax and available options differ from the standard UNRAR package, potentially causing confusion for users following online tutorials.

Choose unrar-free only if you specifically require an open-source solution and primarily work with older RAR formats. For most users, the standard UNRAR package provides better compatibility and functionality.

Method 2: Installing RAR Package for File Creation

While UNRAR handles file extraction, creating RAR archives requires the separate RAR package. This shareware application provides full functionality for creating, modifying, and managing RAR archives.

Install the RAR package using:

sudo apt install rar

The RAR package includes both compression and extraction capabilities. However, remember that RAR is shareware requiring a license for commercial use after the trial period expires. Personal and educational use often falls under acceptable use terms, but verify the licensing requirements for your specific situation.

After installation, verify functionality by creating a test archive:

rar a test.rar /path/to/files

This command creates a new RAR archive named ‘test.rar’ containing the specified files or directories. The ‘a’ parameter stands for ‘add’ and instructs RAR to create or add files to an archive.

Both RAR and UNRAR packages can coexist on the same system without conflicts. Installing both provides complete functionality for all RAR-related operations, making it the recommended approach for users who need comprehensive RAR support.

Method 3: Installing from Official RARLAB Sources

For users requiring the latest features or working with systems where repository packages are unavailable, installing directly from RARLAB sources provides an alternative approach.

Manual Installation Process

Download the latest RAR package for Linux from the official RARLAB website. The process varies depending on your system architecture.

For 64-bit systems, execute the following commands:

cd /tmp
wget https://www.rarlab.com/rar/rarlinux-x64-700b2.tar.gz
tar -zxvf rarlinux-x64-700b2.tar.gz
cd rar
sudo cp -v rar unrar /usr/local/bin/

For 32-bit systems, use the corresponding 32-bit package:

cd /tmp
wget https://www.rarlab.com/rar/rarlinux-x32-700b2.tar.gz
tar -zxvf rarlinux-x32-700b2.tar.gz
cd rar
sudo cp -v rar unrar /usr/local/bin/

This manual installation method places the binaries in /usr/local/bin/, making them available system-wide. The advantage of this approach is access to the latest versions directly from the developer, potentially including features not yet available in repository packages.

Source Code Compilation

Advanced users can compile UNRAR from source code for maximum control over the installation process. Download the source code and compile using:

wget https://www.rarlab.com/rar/unrarsrc-5.9.4.tar.gz
tar -xvf unrarsrc-5.9.4.tar.gz
cd unrar
make -f makefile
sudo install -v -m755 unrar /usr/bin

Source compilation allows customization of build options and ensures optimal performance for your specific system configuration. However, this method requires development tools and may not be necessary for most users.

Basic Usage and Commands

Understanding essential UNRAR commands enables efficient archive management and file extraction. The UNRAR utility offers various options for different extraction scenarios and archive operations.

Essential UNRAR Commands

The most common operation involves extracting files from RAR archives. Use the ‘x’ command to extract files with full directory paths:

unrar x filename.rar

This command extracts all files from the archive while preserving the original directory structure. The extraction process displays progress information and confirms successful completion with an “All OK” message.

List archive contents without extracting files using the ‘l’ command:

unrar l filename.rar

This command provides detailed information about archived files, including names, sizes, dates, and compression ratios. Use this option to preview archive contents before extraction.

Test archive integrity without extracting files:

unrar t filename.rar

The test command verifies that the archive is not corrupted and can be successfully extracted. This verification is particularly useful when working with archives downloaded from unreliable sources or stored on potentially failing storage devices.

Extract files without preserving directory paths using the ‘e’ command:

unrar e filename.rar

This command extracts all files to the current directory, ignoring any subdirectory structure within the archive. Use this option when you need all files in a single location regardless of their original organization.

RAR Creation Commands

Creating RAR archives requires the RAR package rather than UNRAR. The basic syntax for creating archives follows this pattern:

rar a archive.rar files

The ‘a’ command adds files to an archive, creating the archive if it doesn’t exist. You can specify individual files, directories, or use wildcards to include multiple items.

Add password protection to archives using the ‘-p’ option:

rar a -p archive.rar files

The system will prompt you to enter and confirm a password. Password-protected archives provide additional security for sensitive data but remember that forgotten passwords cannot be recovered.

GUI vs Command Line Usage

Ubuntu’s graphical file manager integrates with installed RAR tools, allowing right-click extraction of RAR files directly from the desktop environment. This integration provides convenient access to basic extraction functionality without requiring command-line knowledge.

However, command-line usage offers more options and greater control over the extraction process. Advanced features like selective extraction, password handling, and batch processing are typically only available through command-line interfaces.

Use the graphical interface for simple, one-off extraction tasks, and rely on command-line tools for complex operations, automation, or when working with multiple archives simultaneously.

Advanced Usage and Options

UNRAR provides numerous command-line options for handling specific scenarios and customizing extraction behavior. Understanding these options enables more sophisticated archive management and automation capabilities.

Command Line Options and Flags

Handle password-protected archives by providing the password through command-line options:

unrar x -pPASSWORD filename.rar

Replace “PASSWORD” with the actual archive password. Alternatively, omit the password after ‘-p’ to receive an interactive prompt, which is more secure as it prevents the password from appearing in command history.

Control file overwriting behavior using overwrite options:

unrar x -o+ filename.rar  # Overwrite existing files
unrar x -o- filename.rar  # Skip existing files
unrar x -or filename.rar  # Rename extracted files if conflicts occur

These options prevent accidental file overwrites and provide flexible handling of naming conflicts during extraction.

Extract files to specific directories using the target path option:

unrar x filename.rar /path/to/destination/

This command extracts files to the specified directory rather than the current working directory, providing better organization and preventing clutter in your current location.

Batch Processing and Automation

Process multiple RAR files simultaneously using shell scripting and UNRAR commands. Create simple scripts to handle common batch operations:

#!/bin/bash
for file in *.rar; do
    unrar x "$file"
done

This script extracts all RAR files in the current directory. Modify the script to include error handling, logging, or specific destination directories based on your requirements.

Handle archives split across multiple volumes by specifying the first volume:

unrar x archive.part001.rar

UNRAR automatically processes subsequent volume files when extracting multi-part archives. Ensure all volume files are present in the same directory before beginning extraction.

Troubleshooting Common Issues

Despite UNRAR’s general reliability, users occasionally encounter issues during installation or archive extraction. Understanding common problems and their solutions helps resolve these issues quickly.

Installation Problems

Repository-related errors often occur when package lists are outdated or repositories are temporarily unavailable. Resolve these issues by updating package lists and trying the installation again:

sudo apt update
sudo apt install unrar

Permission denied errors typically indicate insufficient user privileges or system restrictions. Ensure you’re using sudo for installation commands and verify that your user account has administrative privileges.

Package dependency conflicts may arise when multiple archive tools or conflicting versions are installed. Remove conflicting packages and clear the package cache before attempting installation:

sudo apt autoremove
sudo apt autoclean
sudo apt install unrar

Usage and Extraction Issues

“Extraction not performed” errors often indicate corrupted archives or insufficient disk space. Verify that you have adequate free space in the destination directory and test the archive integrity using:

unrar t filename.rar

Corrupted archive handling requires careful analysis of the error messages. UNRAR provides repair functionality for damaged archives:

unrar r archive.rar

The repair function attempts to reconstruct damaged archive structures, but success depends on the extent of corruption. Severely damaged archives may be unrecoverable, making backup copies essential for important data.

Password-protected file issues usually stem from incorrect passwords or character encoding problems. Ensure you’re entering the password correctly and consider that passwords may be case-sensitive or contain special characters that require proper escaping in command-line environments.

File permission problems after extraction can prevent access to extracted files. Modify permissions using standard Linux commands:

chmod -R 755 extracted_directory/

This command grants read, write, and execute permissions to the owner and read and execute permissions to group and other users for all files in the extracted directory.

Alternative Methods and Tools

While RAR and UNRAR packages provide comprehensive RAR support, alternative tools and methods offer additional functionality or different approaches to archive management.

Other Linux distributions use different package managers but follow similar installation principles. Fedora and CentOS users can install RAR tools using DNF or YUM:

sudo dnf install rar unrar  # Fedora
sudo yum install epel-release && sudo yum install rar unrar  # CentOS

Alternative archive managers like 7-Zip provide broad format support including RAR files. Install p7zip-full for comprehensive archive handling:

sudo apt install p7zip-full

The 7-Zip package supports numerous archive formats and offers command-line and graphical interfaces. However, it may not provide the same level of RAR-specific functionality as dedicated RAR tools.

Cloud-based extraction services offer solutions when local installation isn’t possible or practical. These services handle archive extraction through web interfaces, though they require internet connectivity and may raise security concerns for sensitive data.

Comparison with other compression formats reveals trade-offs between compression efficiency, compatibility, and licensing. ZIP archives offer universal compatibility but lower compression ratios. 7Z provides excellent compression with open-source licensing but limited software support. TAR and GZIP remain Linux standards with broad compatibility and integration.

Security Considerations and Best Practices

Working with archives, especially from unknown sources, requires attention to security considerations and best practices to protect your system and data.

Verify archive integrity before extraction using built-in testing functionality. This verification helps identify corrupted files and potential security threats:

unrar t suspicious_archive.rar

Exercise caution when handling archives from untrusted sources, as they may contain malware or malicious scripts. Consider extracting suspicious archives in isolated environments or virtual machines to prevent potential system compromise.

Password management for protected archives requires balancing security and convenience. Use strong, unique passwords for important archives, and consider password managers for storing archive credentials securely. Avoid embedding passwords in scripts or command history where they might be exposed.

Scan extracted files with antivirus software, especially when dealing with archives from internet downloads or email attachments. Many malware samples distribute through archive files to bypass email security filters.

Performance Tips and Optimization

Optimize UNRAR operations for better performance and efficient resource utilization, particularly when working with large archives or limited system resources.

Choose appropriate extraction locations based on available disk space and performance requirements. Extracting to solid-state drives provides faster operation compared to traditional hard drives, while network-mounted directories may introduce significant delays.

Manage system resources during large file extraction by monitoring disk space and memory usage. Large archives may require substantial temporary space during extraction, potentially causing system issues if insufficient resources are available.

Consider extraction priorities when working with multiple archives simultaneously. Extract smaller archives first to complete quick tasks, then handle larger archives during periods of lower system activity.

Regular cleanup and maintenance prevent accumulation of temporary files and outdated archives. Remove extracted files that are no longer needed and organize archives in structured directory hierarchies for easier management.

Storage space considerations become important when working with large archives or limited disk capacity. Monitor available space before beginning extraction operations and consider extracting directly to external storage devices when appropriate.

Congratulations! You have successfully installed rar or unrar. Thanks for using this tutorial for installing rar or unrar in the Ubuntu system. For additional help or useful information, we recommend you check the official rar website

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “Rar/Unrar” installation, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button