How to Extract (Open) a RAR File in Linux

RAR is a file format used for data compression and archiving. The RAR format supports data compression, error recovery and files archives. It also supports files larger than 4 gigabytes. RAR files can only be created through commercial software. You can extract rar file using free unRAR command line tool in Linux.

By default, unRAR is not being installed on Linux or UNIX distro. You need to install unRAR/rar tools with the help of below linux commands.

Install unrar/rar tool

If you are using Redhat Linux or Centos, then use yum command as follows to install unRAR command.

On Redhat/CentOS

sudo yum install unrar
sudo yum install rar

On Ubuntu/Debian

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

On Fedora use dnf command

sudo dnf install unrar
sudo dnf install rar

Listed below are some practical examples of RAR and unRAR command in linux to open,extract and compress files.

1. Extract (open) rar file

If you want to extract all files within the '.rar' file in the current directory run below command

# unrar e log.rar

UNRAR 5.50 freeware      Copyright (c) 1993-2017 Alexander Roshal

Extracting from log.rar

Extracting  dpkg.log                                                  OK
Extracting  tallylog                                                  OK
Extracting  wtmp                                                      OK
Extracting  faillog                                                   OK
Extracting  btmp                                                      OK
Extracting  kern.log                                                  OK
Extracting  auth.log                                                  OK
Extracting  syslog                                                    OK
Extracting  alternatives.log                                          OK
Extracting  lastlog                                                   OK
Extracting  bootstrap.log                                             OK
All OK

2. Extract files with full path

If you want to extract the files in full path. Run below command

# unrar x file1.rar

3. List content of a RAR file

To list files inside rar archive file without extracting. Then use 'l' option

# unrar l log.rar

UNRAR 5.50 freeware      Copyright (c) 1993-2017 Alexander Roshal

Archive: log.rar
Details: RAR 5

 Attributes      Size     Date    Time   Name
----------- ---------  ---------- -----  ----
 -rw-r--r--    531699  2019-10-03 10:54  var/log/dpkg.log
 -rw-------     64064  2019-06-04 15:11  var/log/tallylog
 -rw-rw-r--      2688  2019-10-03 10:50  var/log/wtmp
 -rw-r--r--     32032  2019-06-04 15:11  var/log/faillog
 -rw-rw----         0  2019-02-10 00:06  var/log/btmp
 -rw-r-----     46365  2019-10-03 10:49  var/log/kern.log
 -rw-r-----      1225  2019-10-03 10:55  var/log/auth.log
 -rw-r-----     67588  2019-10-03 10:55  var/log/syslog
 -rw-r--r--     19397  2019-10-03 10:51  var/log/alternatives.log
 -rw-rw-r--    292292  2019-10-03 10:50  var/log/lastlog
 -rw-r--r--     56751  2019-02-10 00:07  var/log/bootstrap.log
----------- ---------  ---------- -----  ----
              1114101                    11

4. Check archive integrity

To test the integrity of file archive use 't' option

 unrar t log.rar

UNRAR 5.50 freeware      Copyright (c) 1993-2017 Alexander Roshal

Testing archive log.rar

Testing     var/log/dpkg.log                                          OK
Testing     var/log/tallylog                                          OK
Testing     var/log/wtmp                                              OK
Testing     var/log/faillog                                           OK
Testing     var/log/btmp                                              OK
Testing     var/log/kern.log                                          OK
Testing     var/log/auth.log                                          OK
Testing     var/log/syslog                                            OK
Testing     var/log/alternatives.log                                  OK
Testing     var/log/lastlog                                           OK
Testing     var/log/bootstrap.log                                     OK
All OK

5. Create a rar single file

To create a .rar archive file use 'a' option.

# rar a log.rar /var/log/
RAR 5.50 Copyright (c) 1993-2017 Alexander Roshal 11 Aug 2017
Trial version Type 'rar -?' for help

Evaluation copy. Please register.

Creating archive log.rar

Adding /var/log/dpkg.log OK
Adding /var/log/tallylog OK
Adding /var/log/wtmp OK
Adding /var/log/faillog OK
Adding /var/log/btmp OK
Adding /var/log/kern.log OK
Adding /var/log/auth.log OK
Adding /var/log/syslog OK
Adding /var/log/alternatives.log OK
Adding /var/log/lastlog OK
Adding /var/log/bootstrap.log OK

6. Create multiple rar files

To compress say ‘file1′, ‘file2′ and ‘file3′ simultaneously, use below command

# rar a file1.rar file1 file2 file3

You can also use the following method to RAR multiple files.

# rar a -r file1.rar file1 file2 file3

7. Set password for RAR file

While archiving, you can set a password (using -p option). If you omit the password on the command line, you will be prompted with a message “enter password” and the password is case sensitive.

# rar a -pQAZWSXEDC archive.rar /var/log/


# rar a -p archive.rar /var/log/

Enter password (will not be echoed):


In this tutorial we learned how to use rar/unrar command in linux to open,extract and create rar files. Hope you enjoyed reading this and please leave your comments below.

Leave a Comment