How To Unrar a File: Unix and Linux

two computers

two computers

Applications, images, documents, and other files of all sorts are most commonly shared across the internet in the RAR format. It is a compressed archive format, and you need to unpack or “unrar” the archives to access the files within them. 

Linux and FreeBSD operating systems do not have the “unrar” command preinstalled. Most UNIX-like systems also do not come with the command preinstalled. 

The unrar command is necessary to unpack these compressed files. Here’s a quick guide to installing and using the unrar command.

Installing the unrar Command

You can use the apt or apt-get command to install the unrar command on Ubuntu and Debian:

$ sudo apt install unrar


$ sudo apt-get install unrar


On Fedora Linux, you can use the dnf command to install unrar, like so:

$ sudp dnf install unrar


On OpenBSD Unix, run this command to install unrar:

# pkg_add -v unrar


The yum command comes in handy if you’re using RHEL or CentOS:

# yum install unrar


You can use the pkg command this way to install unrar on FreeBSD:

# pkg install unrar


If you’re using a macOS Unix or a Homebrew machine, you can use the brew command to install unrar. Bear in mind that on macOS, you will first need to install Homebrew before you can use the “brew” command to install unrar.

Once you’ve installed Homebrew, run: 

$ brew install unrar


If none of these methods work, visit the rarlab website and download the binary package.

Here are the steps to download the package on 32- and 64-bit Linux and install the unrar command:

  1. First, navigate to the /tmp directory
$ cd /tmp


2. If you’re running 32-bit Linux, run the following:

$ wget


3. If you’re running 64-bit Linux, run the following:

$ wget


4. Next, untar the downloaded file:

$ tar -zxvf rarlinux-*.tar.gz


5. You will find the unrar and rar commands in the rar sub-directory. Navigate to the rar directory and type:

$ cd rar

$ ./unrar


6. Next, copy the unrar and rar files to the following directory:

$ sudo cp rar unrar /usr/local/bin


Using the unrar Command

Let’s say you want to unpack a file named “exampleFile.rar.” 

You can run this command to check the contents of a rar archive before extracting it: 

$ unrar l exampleFile.rar


You can then extract the file by running the command this way:

$ unrar e exampleFile.rar