Want to know how to extract a RAR file on Ubuntu? RAR is one of the most common forms of data compression used in the industry. While ZIP allows wider accessibility for the users, RAR retains its prominence over the former due to its reputation for being a better choice for compression.
It is not uncommon for someone to download some files from the web and realize that it is part of a RAR package. So we need to have tools to deal with such files.
What are RAR files?
RAR is a compression method that uses a set of multi-volume files to slip and condense a file’s size. When we need to transfer a large amount of data, this comes in handy as a compressed file is faster to be shared or replicated. These files also take less time to download over the internet compared to non-compressed files.
These advantages make file compression a popular practice. There are many tools available to extract and create RAR files. These tools help a user deal extract files in seconds, irrespective of the size of the archive.
This tutorial was made with a system running Ubuntu 18.04, but you can follow this tutorial if you have the 2 things below.
- Ubuntu/Debian based system (or switch the package install commands based on your distro)
- A non-root user with Sudo privileges
When dealing with RAR files, WinRAR has always given an edge to Windows users over Linux users. Linux users have to download a compatible program or rely on the command line to extract RAR files.
Users have to deal with this issue not just to create a RAR file, but also when they try to extract a RAR file on Ubuntu.
Maybe. The default Archiver on Ubuntu is simply a GUI wrapper for the command line packages available on your system. If you have the unrar package installed, you will be able to extract a rar file without any issues.
But if you don’t have the package installed, and you try to extract a RAR file on Ubuntu by double-clicking it, you won’t be successful.
Instead, you will get a message from the archive manager simply telling you the following.
There is no command installed for RAR archive files. Do you want to search for a command to open this file?
Ubuntu, by default, doesn’t recognize the .rar file type, just like all Linux based systems.
This tutorial will teach you how to install and utilize the tools you need to extract a RAR file on Ubuntu.
Installing the unrar package on Ubuntu
Despite being so popular, files using the RAR compression method is not supported by the default archive manager in Ubuntu. To extract a RAR file on Ubuntu, you need to install a program called UNRAR.
The unrar package is a CLI-based RAR archive manager developed by RARLAB and it is available to Linux users as freeware. unrar is available to Linux users as part of the default Ubuntu repository.
To install unrar on your system, you need to use the command line. Open the terminal on your system and use the apt package manager to install the unrar service. The command should look like this.
sudo apt install unrar
Now, typing the command unrar will help you understand how the archive manager works and how to use it. Your terminal should give an output similar to the one given below.
When you read the user manual of UNRAR, the most common use available for you will be to extract a RAR file on Ubuntu. There are two methods to do this.
This method is pretty straightforward.
- You simply need to go to the location where your RAR file is stored on your system.
- Now you can select your archive
- Right-click to extract it at your desired location.
Now let’s move on to extracting a rar file using the command line on Ubuntu.
Extract a RAR file on Ubuntu using the command line
First, you need to go to the directory where you have saved your RAR file. If the file is not in the home directory, we can use the cd command to shift to the directory holding our RAR file.
In this case, I have saved a rar file in my root directory. Let’s cd to it and extract the file.
Once we are in the right directory, we use the unrar command to extract the contents of our RAR archive. To do this, we simply write the following command in the terminal.
unrar x <filename>.rar
Once done, it will also show you the report on the extraction process. As you can see above, the extraction went ‘All OK’.
Sometimes you need to extract a RAR file on Ubuntu to a location which isn’t the home directory where our archive is saved. For this, make sure you create a directory first if it already doesn’t exist by using the mkdir command.
This is especially useful when the directory which holds the RAR archive is not the same as the directory where we wish to save the extracted files.
unrar e FileName.rar </ExtractLocation/>
As you can see in the screenshot above, I’ve highlighted the section which mentions where the files were extracted.
The use of RAR compression is widespread today. While Linux based systems don’t support .rar files directly, we have tools which can assist us to extract a RAR file on Ubuntu.
This tutorial was based on using UNRAR, a freeware developed by RARLAB, to extract a RAR file on Ubuntu.
While the debate on whether RAR files are better or ZIP will continue, we hope this tutorial was able to help you with extracting RAR files on your system.
If you have any queries, feedback or suggestions, feel free to reach out to us in the comments below.