There is no default utility in CentOS/RHEL 7 systems to extract a .rar file. This post outlines the steps to install the unar package and use of unar command to extract files with .rar extension.
- Log in as a root user (or use sudo) and configure the latest EPEL repositories to be able to install the unar package:
# yum install epel-release
Note: I recommend to disable all the existing repositories and just enable the EPEL repository if you do not want to face any conflict.
- Now you should be able to see the just configured repository:
# yum clean all
# yum repolist
You should be able to see the unrar package listed as well using the below command.
# yum info unar*
For example:
# yum info unar*
Loaded plugins: ulninfo
Available Packages
Name : unar
Arch : x86_64
Version : 1.10.1
Release : 1.el7
Size : 1.9 M
Repo : EPEL
Summary : Multi-format extractor
URL : http://unarchiver.c3.cx/commandline
License : LGPLv2+
Description : The command-line utilities lsar and unar are capable of listing and extracting
: files respectively in several formats including RARv3. unar can serve as a free
: and open source replacement of unrar.
- Now proceed to install the package:
# yum install unar -y
- Once the package is installed, now is possible to extract RAR files. Use the unrar command to extract the .rar files.
# unar [file_name.rar]
For example:
# ll
total 8
-rw-r--r--. 1 root root 72 May 6 10:48 test.rar
#
# file test.rar
test.rar: RAR archive data, v8, os: MS-DOS
#
# unar test.rar
test.rar: RAR 5
test.txt (0 B)... OK.
Successfully extracted to "./test.txt".
#
# ll
total 8
-rw-r--r--. 1 root root 72 May 6 10:48 test.rar
-rw-r--r--. 1 root root 0 May 6 10:48 test.txt
#
Note: View the man page of unrar command for more information and options available.
# man unrar
If you move the original repositories at the beginning of the post, move them back to original place and perform a “clean all”