How To Open and Extract RAR Files In Linux?

Like other archives, a RAR file is a data container that stores one or several files in compressed form. RAR is a proprietary file format which is developed by Eugene Roshal. It is a native file format for the WinRAR archiver. RAR file uses .rar file extension. It is frequently used on Windows OS. If you downloaded a .rar file then first you need to extract it with an application that supports RAR file format and then you can use it. WinRAR application is not available for Linux instead of it we can use rar and unrar programs to create, extract RAR archives.

Ahead in this article, we will discuss how you can extract the RAR file in Linux.

How to Install unrar?

Unrar is an application used to extract .rar files in Linux and Unix. Before you start extracting RAR files you need to install it on your system-

If you are using a Debian based distribution such as Ubuntu, Linux Mint, etc then use –

sudo apt install unrar


sudo apt-get install unrar

Or if you are using an rpm-based Linux distribution such as centos, Redhat, etc then use –

sudo yum install unrar

To install it in Fedora use –

sudo dnf install unrar

Now, unrar is installed and ready to use in your system.

List the files inside the archive

Unrar is installed now before we start extracting rar files we will use a command to list the files that are inside an archive file. To display the list of files and directories use the following command in the terminal. Here, I will extract sample.rar which contains some files inside it –

unrar l sample.rar

Extract the RAR archive

To extract or open a rar file in the current working directory use the unrar command with option e. Now execute the following command to extract the sample.rar file from the terminal –

unrar e sample.rar

Press y if it displays options like given in the image above. This will extract all the files inside the current working directory.

Extract the RAR archive with the original directory structure

If you want to extract files with original directory structure then use the x option with unrar command in the terminal. Use the following command –

unrar x sample.rar

This command will first create the directory named sample and then extract the files inside it.


Now if you want to explore more options that can be used with the unrar command then see its manual page by using-

man unrar

If you have any thoughts related to this article, share it with us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.