How to Create, Extract or Open RAR file in Linux?

Updated on September 16, 2017

Everyone might have used RAR files in Windows, but using it on Linux is not straightforward. None of the Linux operating systems (by default) comes with an utility to process RAR files. It means, if you have downloaded any RAR file from internet and want that to be opened or extracted in Linux machine, then you need a ‘rar‘ and ‘unrar‘ utilities. This tutorial explains how to extract and create rar file in Linux.

Check if your Linux machine already has these utilities.

# whereis rar
# whereis unrar

Install rar and unrar commands in Linux

On Ubuntu or Debian machines

# apt-get rar
# apt-get unrar

On Fedora, Red Hat, CentOS machines…

# yum install rar unrar

rar, unrar linux

In case, if apt-get or yum doesn’t find correct repositories containing rar and unrar utilities, then you may download the binaries as below:

# wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz
# tar xvzf rarlinux-3.6.0.tar.gz
# cd rar
# cp rar unrar /bin

Using unrar to extract RAR archive

# unrar x demos.rar
UNRAR 3.60 freeware Copyright (c) 1993-2006 Alexander Roshal
Extracting from demos.rar
Extracting xbpdemo.mov OK
Extracting bpbdemo.mov OK
Extracting drback.mov OK
Extracting flaskbo3.mov OK
Extracting q35fun.mov OK
All OK

List files inside RAR archive

# unrar l demos.rar

Test the RAR file integrity

# unrar t demos.rar

To create a RAR archive in Linux

# rar a sample.rar files/

Here, command ‘a‘ is for creating an archive.

rar and unrar commands/options

Lookout for various commands or options by just typing the command.

# rar
Usage: rar <command> -<switch 1> -<switch N> <archive> <files...>
<@listfiles...> <path_to_extract\>
<Commands>
 a Add files to archive
 c Add archive comment
 cf Add files comment
 ch Change archive parameters
 cw Write archive comment to file
 d Delete files from archive
 e Extract files to current directory
 f Freshen files in archive
 i[par]=<str> Find string in archives
 k Lock archive
 l[t,b] List archive [technical, bare]
 m[f] Move to archive [files only]
 p Print file to stdout
 r Repair archive
 rc Reconstruct missing volumes
 rn Rename archived files
 rr[N] Add data recovery record
 rv[N] Create recovery volumes
 s[name|-] Convert archive to or from SFX
 t Test archive files
 u Update files in archive
 v[t,b] Verbosely list archive [technical,bare]
 x Extract files with full path

Similarly, below are the options for ‘unrar’ command

# unrar
Usage: unrar <command> -<switch 1> -<switch N> <archive> <files...>
 <@listfiles...> <path_to_extract\>
<Commands>
 e Extract files to current directory
 l[t,b] List archive [technical, bare]
 p Print file to stdout
 t Test archive files
 v[t,b] Verbosely list archive [technical,bare]
 x Extract files with full path

Was this article helpful?

Related Articles

Leave a Comment