blog image

Using Unrar for Unzipping RAR Files on Linux

Working with compressed archives is something every Linux user encounters at some point. While .zip and .tar.gz files are common, you’ll often find files distributed in the .rar format — especially when downloading videos, documents, or software from the internet. Unlike .zip, Ubuntu doesn’t come with built-in support for .rar, so you’ll need to install a tool called unrar.

In this post, we’ll go step by step, from installation to extracting files, and address common pitfalls you might face when working with .rar archives on Ubuntu.


Step 1: Install Unrar

First, update your system and install unrar:


 

sudo apt update sudo apt install unrar

This installs the utility you’ll use to manage .rar files.


Step 2: List the Contents of a RAR File

Before extracting, you might want to see what’s inside the archive. Use:


 

unrar l Btfly.rar

Example output:


 

Archive: Btfly.rar Details: RAR 4 Attributes Size Date Time Name ----------- --------- ---------- ----- ---- I.A.... 263390066 2025-08-13 19:41 Butterfly.2025.S01E04.720p.WEB.x265.HEVC.mkv I.A.... 500 2025-01-01 21:25 Todaytvseries.txt ----------- --------- ---------- ----- ---- 263390566 2

Here you can clearly see the two files inside: a video file and a small text file.


Step 3: Extract the RAR File

To extract the contents into your current directory, simply run:


 

unrar x Btfly.rar

This will unpack all files into the folder where the .rar archive is located.


Step 4: Extract to a Specific Directory

If you want to extract into a different directory, you need to specify a path. For example:


 

unrar x Btfly.rar ~/Videos

This command extracts the files into your ~/Videos folder.

⚠️ Important note:
Unlike unzip, unrar does not create missing directories automatically. If you try something like:


 

unrar x Btfly.rar cd/Videos

and the cd/Videos folder doesn’t exist, you’ll get:


 

No files to extract

To fix this, first create the folder and then run the command:


 

mkdir -p cd/Videos unrar x Btfly.rar cd/Videos


Step 5: Test the Archive Without Extracting

To check if the archive is valid (useful when you’re unsure if the download is corrupted), use:


 

unrar t Btfly.rar

This will test the archive’s integrity without unpacking the files.


Bonus: One-Liner Command to Auto-Create Directory and Extract

To make life easier, you can combine mkdir -p and unrar in a single command:


 

mkdir -p ~/Videos/Btfly && unrar x Btfly.rar ~/Videos/Btfly

This will:

  1. Create the folder ~/Videos/Btfly if it doesn’t already exist.

  2. Extract all files from Btfly.rar straight into that folder.


Final Thoughts

Using unrar is simple once you know the basics:

  • unrar l file.rar → list contents

  • unrar x file.rar → extract here

  • unrar x file.rar /path/to/folder → extract to specific directory

  • unrar t file.rar → test archive integrity

  • mkdir -p /path && unrar x file.rar /path → one-liner that auto-creates the folder

With these commands, you can confidently handle .rar files on Ubuntu just as easily as .zip archive

Share
Tags
Leave A Reply