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

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 an ‘rar‘ and ‘unrar‘ utilities.

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

And you might know on Windows, you need Winrar to extract or create a RAR archive.

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
# 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 OK
Extracting OK
Extracting OK
Extracting OK
Extracting 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\>
 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\>
 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

Related Content

vps germany
Disclaimer: The content published in this article is the views of the author only. Techglimpse does not gurantee accuracy, completness or validity. If you believe the content on this post violates your copyright, please send us a mail for removal. Read more.