how to open, extract rar files in Linux

How to Open, Extract RAR Files in Linux

RAR files are compressed file formats used to pack a lot of data in a small space. Its advantage is that it allows you to split compressed files over multiple volumes and then combine them during extraction. In this article, we will look at how to open, extract RAR files in Linux.


How to Open, Extract RAR Files in Linux

Here are the steps to open, extract RAR files in Linux. For this, we will need to install unrar utility tool in Linux since it is not present by default.


1. Install unrar

Open terminal and run the following command to install unrar on your Linux system.

Debian/Ubuntu

$ sudo apt-get install unrar

Redhat/CentOS/Fedora

$ sudo dnf install unrar


2. Extract RAR file

Run the following command to unrar a RAR file. Replace file.rar with your RAR file name. Please note, there is no hyphen before ‘e’ option below.

$ sudo unrar e file.rar

The above command will extract all files & subfolders present in file.rar into present directory.

If you want to extract the file to a specific folder, just add the folder (e.g. /home) above after the rar file name.

$ sudo unrar e file.rar /home

The above command will extract all files & subfolders present in file.rar into /home directory.

If you want to extract all files to the RAR file’s original directory use x option.

$ sudo unrar x file.rar

The above command will create /file folder in your present working directory and extract all files & subfolders to this folder.


3. Extract Multipart RAR file

If you have a multi-part RAR file, make sure all the other parts are in the same folder. Then unrar only the first part file.

$ sudo unrar e file-part-1.rar

Unrar tool will automatically look for other parts in the same folder, extract and combine them together.


4. View contents of RAR file

If you want to simply view the contents of RAR file without actually extracting it, use the ‘l’ option.

$ sudo unrar l file.rar

It will list all files & folders present in your RAR file, along with their name, size, time created and permissions.

You can also test all the files in your RAR file to see if they are ok, with the following command.

$ sudo unrar t file.rar

That’s it. In this article, we have seen how to open, extract RAR file using unrar tool.

Also read :

How to Stop Linux Package from Updating in Linux
How to Generate PGP Key in Linux
How to Log Shell Script Output to File
Find PID of Process Running On Port
How to Check if Port is Open or Closed in Linux

Leave a Reply

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