How to Open and Extract RAR Files in Linux?

How to Open and Extract RAR Files in Linux?

The RAR file format compresses large files into smaller ones so they can be sent easily over the internet. When downloading a .rar file from the web, we need to use a rar tool to extract (uncompress) its contents.

The RAR file format is freely available for Windows operating systems—but the rar tool, which handles compressed files, isn’t installed on Linux by default.

This article will explain how to install the Unrar command-line tool on a Linux system.

Step 1: Installing Unrar on Linux

The program of apt or apt-get can be used to install unrar on Debian and Ubuntu-based distributions.

$ sudo apt-get install unrar
$ sudo apt install unrar
Using RHEL-based distributions, use DNF or yum to install it.

$ sudpdnf install unrar
You will need to download and install a recent version of rar/unrar for users of other Linux distributions by the following command.

--------------- On 64-bit ---------------

# cd /tmp
# wget
# tar -zxvf rarlinux-x64-612.tar.gz
# cd rar
# sudo cp -v rarunrar /usr/local/bin/

--------------- On 32-bit ---------------

# cd /tmp
# wget
# tar -zxvf rarlinux-x32-612.tar.gz
# cd rar
# sudo cp -v rarunrar /usr/local/bin/

Step 2: How to Extract a Linux file of RAR File

To extract or open the file of RAR use this command: unrar e in the directory where you work currently.

# unrar e hoststud.rar
For extracting and opening the file of RAR and placing its contents in another location, use the unrar e command with an option that specifies where you want to put the files.

# unrar e hoststud /home/
To extract a RAR file with its original directory structure, use the below command: unrar x (source). According to the structure given, it would start to extract the command output:

# unrar x hoststud.rar

Step 3: How to Add a RAR File to Linux

For listing the archive file content, use the mentioned command unrar l. You can see the list of files logged in time, date, and size at the time of creation.

unrar l hoststud.rar

Step 4: Testing Your RAR File in Linux

Here, we are testing the archive file for integrity, using the option unrar t. The command mentioned below is about to perform the file integrity and checks the file status too.

unrar t hoststud.rar
The unrar command can be used to extract, list, and test RAR files—but it has no option for creating them. So we have to start the installation of the tools command-line RAR for creating the archive files.

Step 5: To install RAR on Linux, follow these steps

You can install the RAR command option in Linux by executing this command:

# sudo apt-get install rar
# sudo DNF install rar
# yum install rar

Step 6: Create a RAR File in Linux

Run the command mentioned below for creating the RAR archive file. You can start using the mentioned command with the rar option:

rar a hoststud.rarhoststud

Step 7: How to Delete files from the Archive

To remove a file from an archive, run this command.

rar d filename.rar

Step 8: How to Recover a Deleted File

When trying to recover or fix an archive file, it is advisable to run the command with the option

rar r.
rar r filename.rar

Step 9: Step to Update Archives

To add or update files in an existing archive, use the command rar u.

rar u hoststud.rarhoststud.sql
Confirm that hoststud.sql is one of the files added to your archive file.

rar l hoststud.rar
Step 10: Setting a password for archive files

To password-protect, a RAR archive file, use the command line option rar a –p.

rar a -p hoststud.rar
Let us extract the archive file and see whether a password prompt appears.

rar x hoststud.rar
Step 11: How to Protect Your Archives

RAR Tool lets you lock an archive file after extracting its contents.

rar k hoststud.rar


We have discussed all the steps to open, extract and protect the rar files. Follow the steps to accomplish your task.
First release
Last update
0.00 star(s) 0 ratings

More resources from kumkumsharma