How to Open, Extract and Create RAR Files in Linux

RAR is most popular tool for creating and extracting compressed archive (.rar) files.

Install Unrar in Linux

## RHEL/CentOS 6 32-Bit ##

# wget
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.i686.rpm

RHEL/CentOS 5 32-Bit ##
# wget
# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

RHEL/CentOS 4 32-Bit ##
# wget
# rpm -Uvh rpmforge-release-0.5.2-1.el4.rf.i386.rpm
RHEL/CentOS 6 64-Bit ##
# wget
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

RHEL/CentOS 5 64-Bit ##
# wget
# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

RHEL/CentOS 4 64-Bit ##
# wget
# rpm -Uvh rpmforge-release-0.5.2-2.el4.rf.x86_64.rpm

Once you’ve enabled RPMforge repository for systems. Follow the below instillation instructions with their examples.

Install Unrar in Linux
# yum install unrar
Open/Extract a RAR File in Linux

To open/extract a RAR file in current working directory, just use the following command withunrar e option.

#unrar e test.rar

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

#unrar e test.rar /media/

To open/extract a RAR file with their original directory structure. just issue below command with unrar x option. It will extract according their folder structure see below output of the command.

#unrar x test.rar
List a RAR File in Linux

To list a files inside a archive file use unrar l option. It will display the list of files with theirsizes, date, time and permissions.

unrar l test.rar
Test a RAR File in Linux

To test an integrity of a archive file, use option unrar t. The below command will perform a complete integrity check for each file and displays the status of the file.

unrar t test.rar

The unrar command is used to extract, list or test archive files only. It has no any option for creating RAR files under Linux. So, here we need to install RAR command-line utility to create archive files.

Install Rar in Linux

To install RAR command option in Linux, just execute following command.

yum install rar
Create Rar File in Linux

To create a archive(RAR) file in Linux, run the following command with rar a option. It will create archive file for a tecmint directory.

rar a test.rar test
Delete files from Archive

To delete a file from a archive file, run the command.

rar d filename.rar

Leave a comment