I have a file with .rar
extension, ex: foo.rar
I want to extract content from that file, how do I extract it?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI have a file with .rar
extension, ex: foo.rar
I want to extract content from that file, how do I extract it?
You can install unrar
- "Unarchiver for .rar files" or unp
- "unpack (almost) everything with one command"
To unrar
a file:
unrar x <myfile>
To unp
a file:
unp <myfile.rar>
Since unrar
is not open source, some distros might not have it in their package manager already. If it's not, try unrar-free
.
Notice that unrar x <myfile>
will preserve directory structure in archive, in difference with unrar e <myfile>
which will flatten it
rar
command. It is binary-only and a bit less easy to use, but can open some files that unrar
cannot.
– Wouter Verhelst
Dec 1 '15 at 6:47
sudo apt install unrar
. This is the official version and it has license prohibing some usage (no compression, only decompression). So you can also use the free version instead: sudo apt-get install unrar-free
.
– tsveti_iko
May 12 '20 at 16:29
You can use unar
. This is not related to the non-free unrar
, it's free software.
Easy to use:
unar file.rar
rar
is not open source, so much that 7-Zip on OSS distributions will not ship with it, how did unar
manage to include it?
– palswim
Jan 31 '19 at 0:57
unar
that unrar
not have, a file of 49750384 bytes, "Failed! (Attempted to read more data than was available)". Sorry, bad program.
– Peter Krauss
May 24 '20 at 13:16
sudo apt-get install p7zip # debian based systems
sudo yum install p7zip # CentOS based systems
7zr x myfile.rar
On Windows I rely on 7zip for rar and every other archive file, and it works on Linux, too.
sudo yum install p7zip
and 7za x myfile.rar
. (I have tried many other packages but none is in RHEL)
– ch271828n
Oct 14 '19 at 1:02
You can get unar from fedora repo, it's open and licence-pure:
dnf install unar
unar file.rar
unrar
is not open source (it is forbidden to analyze the code to reverse engineer a compression program), so Fedora won't ship it.
– vonbrand
Feb 23 '16 at 10:24
Note that unrar
is not open source (the license to the available source forbids using it to reverse engineer the compression, which violates point 6 "No Discrimination Against Fields of Endeavor" of the Open Source Definition), and thus will not be shipped by Fedora.
Go to Rar Labs, check out the source for unrar
(be careful, the version might have changed!), build and install (you'll need g++ and make), preferably for your account only:
$ tar zxf unrarsrc-5.3.11.tar.gz
$ cd unrar
$ make DESTDIR=$HOME all
$ make DESTDIR=$HOME install-unrar
Add $HOME/bin
to your PATH
, and you are all set.
Yes, there is a RPM offered. I would't touch it with the proverbial 10 feet pole, more often than not third parties have no clue on how to create a correct RPM (it isn't exactly rocket science, but there are lots of details that have to be just right, see e.g. Fedora's guidelines). Besides, there are differences between Fedora versions, "one size fits all" can't cut it.
Use RAR rar e <filename>
it comes with most distros. Created by brother of Eugene Rosahal who is the developer of RAR files.
On Ubuntu and Fedora (and perhaps other distributions as well), you have a GUI solution, Archive Manager. It provides extraction of such archive files as .rar
files.
.rar
extension name to Archive Manager. With the hint of this answer, I open the Archive Manager manually, and then use it to open the .rar
file. It works like a charm!
– RayLuo
Jan 6 at 6:51
.rar
is linked to be opened with Archive Manager in Nautilus (maybe this is the default on Gnome), and even there is an option in the menu here (Fedora Gnome). Maybe something is out-of-date there, or you're not on Gnome? By the way, I'm happy to provide a simple solution for you!
– MAChitgarha
Jan 6 at 14:04
I'd suggest using a nearest available file manager, either Norton-like (Midnight Commander
, Double Commander
, Tux Commander
, etc., whatever is present in your distribution) or window-based (as Dolphin
). Most of them have enough intelligence to open all kinds of archives in a manner suitable for manual contents exploring, but, sometimes, they use external tools. For instance, my Kubuntu suggests Ark
in such cases. They would need an external tool, as unrar
, for accessing proprietary archive formats; if so, install the latter using a package manager.
If you want to extract the entire archive or a single specified file, unrar e
extracts without full path, and unrar x
also makes intermediate directories.
unrar
is not open source, Fedora won't ship support for it in any form.
– vonbrand
Feb 23 '16 at 12:59
urar
to exist beforehand.
– RayLuo
Jan 6 at 6:53
Install the unrar
package. On Fedora, for eample, you can do so with:
sudo yum install unrar
Then, use it to extract the files:
unrar e filename.rar
unrar
package among its official packages. I got the source an installed it in my account.
– vonbrand
Feb 23 '16 at 10:20
For Linux Ubuntu and Mint
sudo apt install unar
unar file_name.rar
Extract an archive to the current directory:
unar {{archive}}
Extract an archive to the specified directory:
unar -o {{path/to/directory}} {{archive}}
Force overwrite if files to be unpacked already exist:
unar -f {{archive}}
Force rename if files to be unpacked already exist:
unar -r {{archive}}
Force skip if files to be unpacked already exist:
unar -s {{archive}}
7z x foo.rar
. – user140866 Dec 1 '15 at 6:047z(1)
states thatrar
support was removed due to non-open license.rar
is not open source, and this *** will not*** be shipped by Fedora. – vonbrand Feb 23 '16 at 12:39unrar
from source Then Xarchiver can extract files. Or you can unrar on command line, but consider if passwords contains special characters use '\' before them for exampleunrar x -pwww\.irlanguage\.com file.rar
– EsmaeelE Dec 16 '19 at 19:32