How to extract RAR file in Ubuntu?

You can’t extract RAR files in Ubuntu, as it lacks the necessary capabilities to do so. But don’t worry, there are several methods available to help you. Unrar and 7-Zip are some of the most popular tools for unrar files on Ubuntu 22 and other versions.

This guide is designed for Ubuntu, but the commands are also used in other Linux distributions such as Fedora, Debian, Arch Linux.

How to Installing RAR Extraction Tools in Ubuntu terminal?

Since the Linux operating system cannot extract RAR files buy default, we must install Unrar or 7-Zip tools, but before that we must update the Ubuntu server packages.

sudo apt update

Install Unrar in Ubuntu

Unrar is the official tool for handling RAR files.

sudo apt install unrar

Tip: When you update Ubuntu repositories, the unrar (non-free) and unrar-free packages may appear or be already installed.

install 7-zip in Ubuntu

7zip is a versatile tool that supports multiple archive formats, including RAR.

sudo apt install p7zip-full

Tip: p7zip-full supports RAR extraction, while p7zip alone does not.

If you haven’t ordered your Linux server yet, you can choose from our Linux VPS plans with different combinations at reasonable prices.

How to Extracting RAR Files in Ubuntu using Command Line?

To extracting RAR file in same directory or unrar along with moving the file to another directory in Ubuntu, we need to use the following commands.

Extracting a Single RAR File

To extract a RAR file in the current directory :

Using unrar

unrar x FileName.rar

x (Extract with full path) means is extracts the files along with the main directory structure inside the archive. This option is suitable for when you want to preserve the folder structure.

In case you wish to extract the RAR file into the current working directory, without preserving the original directory structure, use the “e” switch instead of x.

unrar e FileName.rar

Using 7zip

7z x FileName.rar

Extracting to a Specific Directory

If you want to extract the contents to a particular directory, use the -o option.

Using unrar

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

Using 7zip

7z x FileName.rar -o/path/to/destination/

Password Protected RAR File Unlock

Sometimes, RAR files are secured with a password. Both unrar and 7zip can handle password-protected archives.

When we extract a file, it may ask you for a password after extraction, but we can enter the password in this extraction using the following commands:

Using unrar

unrar x -pYOURPASSWORD FileName.rar

Using 7zip

7z x FileName.rar -pYOURPASSWORD

Caution: Supplying passwords directly in the command line can be insecure, as they may be visible in command history or process lists.

Extract Multi Part RAR Files

Large files are often split into multiple RAR parts to reduce file download and upload size (eg, archive.part1.rar , archive.part2.rar, etc.).

To extract such archives, make sure that all the files are in one directory, then extract the first part using the unrar or 7zip tools with the following command:

Extract Multi Part RAR Files using unrar

unrar x archive.part1.rar

Extract Multi Part RAR Files using 7zip

7z x archive.part1.rar

Tip: The important thing here is that when the extraction process starts, it automatically detects and processes the next parts.

Common Errors and Troubleshooting in Extract RAR File

In the execution of some cases, you may encounter some errors such as CRC or Unsupported Archive Format. Now let’s check those errors together.

CRC Error in extracting RAR file

CRC (Cyclic Redundancy Check) error when extracting RAR files in Ubuntu usually occurs due to data corruption or archive file problems. This error indicates that part of the data in the archive file is corrupted or incomplete. Below are some of the main causes of CRC errors:

Error Massage:
CRC failed in file 'filename'

Solutions:

Re-download the Archive: The file might have been corrupted during download.
Verify Integrity: If available, check the archive’s checksum against the source.
Repair the Archive: unrar offers a repair feature.

Enter the following command to restore the RAR file:

unrar r archive.rar

Note: Repairing is only partially effective and depends on the extent of corruption.

Unsupported Archive Format error in Extracting RAR file

An “Unsupported Archive Format” error means that the software you are using to extract the file is unable to recognize or support the desired compressed file format.

Error Message:
Can't find end of central directory

Solutions:

Re-download the Archive: Ensure the download completes without interruptions.
Check File Naming: Ensure all parts of multi-part archives are correctly named and present.

Sometimes it is possible to delete the directory created by RAR files due to failure or completion of work. For this purpose, you can read the tutorial Delete the directory in Linux.

Conclusion

It is common for large files to be compressed using the RAR format in order to release storage space on a computer or server. However, Ubuntu, the Linux based operating system, fails to extract RAR files. In this article, we discussed how to extract RAR files in Ubuntu using Unrar and 7-Zip.


author image

The Author Robert Smite

Hello! I'm Robert, specializing in virtual servers and cloud technology. With expertise in managing and optimizing virtual servers, my focus is on delivering understandable and practical content in this field. My goal is to enhance knowledge and assist individuals in selecting the best virtual services for their needs.

More from Robert Smite

Post Your Comment

Your email address will not be published. Required fields are marked *