How to Create, Extract and List RAR Files in Linux

RAR files, a common compressed file format, are widely used to store and share large amounts of data efficiently. While Linux natively supports various compression formats like ZIP and TAR.

RAR is the most popular tool for creating and extracting compressed archive (.rar) files. When we download an archive file from the web, we require a rar tool to extract them.

RAR is available freely under Windows operating systems to handle compressed files, but unfortunately, the rar tool isn’t pre-installed under Linux systems.

In this article, we’ll guide you through the process of installing unrar and rar command-line tools to open, extract, uncompress, or unrar and create an archive file on a Linux system.

Install rar and unrar on Linux

To work with RAR files on Linux, you’ll need the rar and unrar command-line utilities, which allow you to create and extract content from RAR archives.

To install rar and unrar, open a terminal and use the default package manager specific to your Linux distribution.

For example, on Debian and Ubuntu-based distributions, you can easily install the rar and unrar packages using the apt-get or apt program as shown.

$ sudo apt-get install rar unrar
$ sudo apt install rar unrar

If you are using RHEL-based distributions, you can use the dnf command or yum command to install it.

------------ On Fedora Linux ------------ 
$ sudo dnf install rar unrar        

------------ On RHEL-based Linux ------------
$ sudo yum install epel-release
$ sudo yum install rar unrar

On other popular Linux distributions, you can install it using your default package manager as shown.

$ sudo emerge -a rar unrar          [On Gentoo Linux]
$ sudo apk add rar unrar            [On Alpine Linux]
$ sudo pacman -S rar unrar          [On Arch Linux]
$ sudo zypper install rar unrar     [On OpenSUSE]    

If your distribution does not offer rar and unrar packages, you need to download the latest unrar/rar file and install it using the following commands.

--------------- On 64-bit --------------- 
# cd /tmp
# wget
# tar -zxvf rarlinux-x64-700b2.tar.gz
# cd rar
# sudo cp -v rar unrar /usr/local/bin/

--------------- On 32-bit --------------- 
# cd /tmp
# wget
# tar -zxvf rarlinux-x32-700b2.tar.gz
# cd rar
# sudo cp -v rar unrar /usr/local/bin/

How to Create RAR File in Linux

To create an RAR archive file in Linux, run the following command with a option, which will create an archive file for a tecmint directory.

$ rar a tecmint.rar tecmint
Creating RAR File in Linux
Creating RAR File in Linux

How to Extract RAR Files in Linux

Once you have unrar installed, you can easily open or extract the contents of a RAR file in the current working directory by using the following command with the e option.

$ unrar e tecmint.rar
Extracting RAR Files
Extracting RAR Files

How to Extract RAR File to a Specific Directory

To open/extract a RAR file in a specific path or destination directory, use the e option, it will extract all the files in the specified destination directory.

$ unrar e tecmint.rar /home/tecmint/rarfiles
Extracting RAR Files to Directory
Extracting RAR Files to the Directory

How to Extract RAR File with Directory Structure

To open/extract an RAR file with its original directory structure, just issue the below command with the x option, which will extract according to their folder structure see below the output of the command.

$ unrar x tecmint.rar
Extracting RAR Files with Directory Structure
Extracting RAR Files with Directory Structure

How to List RAR Files in Linux

To list the contents of an RAR file in Linux, you can use the unrar l command, which will display the list of files with their sizes, dates, times, and permissions.

$ unrar l tecmint.rar
Listing Content of RAR Files
Listing Content of RAR Files

How to Check Integrity of RAR File in Linux

To check the integrity of an RAR archive file, you can use the unrar t command, which will perform a complete integrity check for each file for errors and displays the status of the file.

$ unrar t tecmint.rar
Testing RAR Files
Testing RAR Files

The unrar command only extracts, lists, or tests archive files. It has no option for creating RAR files under Linux. So, here we need to install the RAR command-line utility to create archive files.

How to Delete Files in RAR Archive

The rar d command is used to delete files from an existing RAR archive in Linux. The d option directly modifies the existing RAR archive by removing the specified files.

$ rar d tecmint.rar randfile001 randfile002 

In the above command, the randfile001 and randfile002 files will be deleted from the tecmint.rar RAR archive.

Delete Files in RAR Archive
Delete Files in the RAR Archive

How to Repair RAR Files in Linux

The rar r command is used to repair and recover data from damaged or corrupted RAR archives in Linux.

$ rar r tecmint.rar
Repair RAR Archive
Repair RAR Archive

How to Add Files to RAR Archive

To update or add files to the existing archive file, use the rar u command, which allows you to add files to an existing RAR archive or update files within the archive.

$ rar u tecmint.rar

Now, verify that the file tecmint.sql is added to the archive file.

$ rar l tecmint.rar
Add Files to RAR Archive
Add Files to the RAR Archive

How to Set Password to RAR File

This is a very interesting feature of the rar tool, which allows us to set a password to the RAR archive file using the following command.

$ rar a -p tecmint.rar
Set Password to RAR File
Set Password to RAR File

Now verify it by extracting the archive file and see whether it will prompt us to enter the password that we have set above.

$ rar x tecmint.rar
Extract Password Protected RAR File
Extract Password Protected RAR File

How to Lock RAR File

The rar k command is used to lock an existing RAR archive file, which is useful if you want to prevent further modifications to the archive.

$ rar k tecmint.rar
Lock RAR File
Lock RAR File

How to Split a RAR Archive

To split a RAR archive into 50MB parts or segments, use the following command with the -v50M option, which will split RAR file into four parts.

rar a -v50M archive_name.part.rar file1 file2 directory

Make sure to replace “archive_name.part.rar” with your desired archive name and size with the desired size (e.g., 50M or 100M). Include the files or directories you want to compress.


For more RAR and Unrar options and usage, run the following command it will display a list of options with their description.

$ man unrar
$ man rar

We have presented almost all the options above for rar and unrar commands with their examples. If you feel that we’ve missed anything in this list and you would like us to add, please update us using the comment form below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. 2020-Nov update:
    sudo apt-get install rar
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package rar is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

        • @ikomrad

          On Debian system, the unrar tool is not included in the default repositories due to licensing issues. Instead, you can use the unrar-free package, which provides a free and open-source version of the unrar utility.

          sudo apt-get install unrar-free
    • @Khalequzzaman,

      To unrar a file to a different or specific directory, you can use the unrar command with the x and -o+ options to specify the output directory.

      unrar x archive_name.rar -o+ /path/to/destination
    • @Max,

      To extract multiple RAR files into a single or specific directory, you can use the unrar command with wildcards to match the file names.

      unrar x '*.rar' /path/to/destination
  2. I’m a bit of a noob and was trying to compress a large Directory of files to smaller archive volumes of about 200mb with a comment included from file and this is what I came up with, please feel free to refine My command.:

    rar a -z/Location of comment file/COMMENT.txt -v2048M -vn -m5 archivename.ra DirectorNameOfSourceFiles

    • I recognized My mistakes I think and ended up using the following:

      rar a -m5 -v204800k -vn -z/LocationOfComment/COMMENT.txt ArchiveName.rar SourceDirectory

      Any input would be very valuable TY

      • @NeophobiA,

        Your attempt to create a RAR archive with specified options looks quite close! However, there’s a small adjustment needed in the placement of the comment file option.

        rar a -v2048M -vn -m5 -z"/Location/of/comment/file/COMMENT.txt" archivename.rar DirectorNameOfSourceFiles
  3. I have been trying to unrar a partitioned ISO file I downloaded recently, what is the command to not only unrar the first file but the other partitions so that it all decompresses consecutively?

    It has 6 parts in all.

    • @Ark,

      To unrar a partitioned ISO file with multiple parts consecutively, you can use the unrar command in the following way:

      unrar x part01.rar /path/to/destination

      The above command will automatically detect and extract the subsequent parts as long as they are in the same directory as the first part.

  4. Does nobody use WinRAR? I wouldn’t touch 7zip if nothing else was available out there. I can still easily add additional files to WinRAR archives, whereas with 7zip I can’t. I have to unzip the archive, then add additional files and then zip it all up again.

    • @Vini,

      Many people use WinRAR, and it has been a popular compression tool for Windows users for many years.

      While 7-Zip is also a widely used compression tool, but does have some differences as compared to WinRAR, including the behavior you’ve noted regarding updating existing archives. Users often choose between these tools based on their specific requirements.

      Ultimately, the choice between WinRAR and 7-Zip depends on individual preferences and the specific needs of the user.

  5. How to unrar a .rar file without listing all the filenames but just the percentage status of extracting?

    This code that I run:

    !unrar x Concrete-Crack-Images-for-Classification.rar @

    is not enough. It does not show the percentage status of extracting.

    • @Sing,

      To unrar a .rar file by displaying the percentage status of the extraction without listing all filenames, you can use the -inul (stands for “no list”) option along with the -p option to specify the password if the file is encrypted.

      unrar x -pYourPassword -inul archive_name.rar
    • @Supergirl,

      Yes, are correct. Engrampa is a graphical user interface (GUI) based archive manager for managing compressed files on Linux, and it supports various archive formats, including ZIP and RAR.

    • @Fadie,

      The simple way to open a rar file in Linux, use:

      # unrar e tecmint.rar

      And those 10 commands are examples to play with rar files in Linux..

  6. I have installed BackTrack 5 R3 on VMware. Now, I want to extract a RAR file located on the desktop, but I am facing difficulties. I have used the following command:

    unrar e video.rar

    Please help me.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.