- How to open rar file in linux?
- 11 Answers 11
- Installation
- Usage
- More info
- How to Extract RAR Files in Ubuntu Linux
- What is a .RAR File Extension?
- Extracting RAR Files in Linux distributions
- How to Install Unrar tool in Linux
- How to Extract a RAR File in Linux
- How to View Contents inside a RAR File in Linux
- Testing a RAR File in Linux
- Installing RAR in Linux
- Creating RAR Files in Linux
- Deleting Files from any Archive
- Recovering deleted Archives
- Setting password on a Particular Archive
- Wrap Up
How to open rar file in linux?
I have a file with .rar extension, ex: foo.rar I want to extract content from that file, how do I extract it?
11 Answers 11
You can install unrar — «Unarchiver for .rar files» or unp — «unpack (almost) everything with one command»
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 will preserve directory structure in archive, in difference with unrar e which will flatten it
There is also a rar command. It is binary-only and a bit less easy to use, but can open some files that unrar cannot.
I needed to first install it by running 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 .
You can use unar . This is not related to the non-free unrar , it’s free software.
@vonbrand: availability depends on the specific GNU/Linux distribution. For example unar is available for Parabola GNU/Linux-libre. Anyway I didn’t mention «unrar», and unar != unrar
If 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, rar is simply a proprietary format and the rar tool is an implementation (which has a non-open license). unar is another implementation that is free. Fedora removed the non-free rar tool due to its license, not because of anything regarding the rar format itself
Hum.. functional problem in unar that unrar not have, a file of 49750384 bytes, «Failed! (Attempted to read more data than was available)». Sorry, bad program.
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.
You can get unar from fedora repo, it’s open and licence-pure:
dnf install unar unar file.rar
Not available. unrar is not open source (it is forbidden to analyze the code to reverse engineer a compression program), so Fedora won’t ship it.
also you can use unar for fedora 23. did the author of the question asked about feora or opensource sollution or about unix rar sollution? @vonbrand
For Linux Ubuntu and Mint
Installation
Usage
More info
- Extract an archive to the current directory: unar >
- Extract an archive to the specified directory: unar -o >>
- Force overwrite if files to be unpacked already exist: unar -f >
- Force rename if files to be unpacked already exist: unar -r >
- Force skip if files to be unpacked already exist: unar -s >
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.
Update: There is a RPM for unrar version 6.0.5 in the RPM Fusion repository for Fedora 34. The license is cited as «Freeware with further limitations».
How to Extract RAR Files in Ubuntu Linux
When it comes to handling zip files, Windows users have always had the advantage with WinRAR that automatically helps to extract and compressing zip files. On the other hand, in case of Linux operating systems, users have to either download other compatible tools or perform the operation through command terminal.
What is a .RAR File Extension?
For users who don’t know, a RAR file is a compressed file that is split into a set of multi-volume files. This is usually done in cases where there are large file sets that are needed to be shared or transferred, hence are compressed into a zip file. Similarly, for zip files, when they are transferred or downloaded from the internet need to be extracted. A number of tools are available to help extract and compress these files within seconds, regardless of their size or quantity.
Extracting RAR Files in Linux distributions
RAR is a free tool that is pre-installed on Windows operating systems but unfortunately doesn’t support Linux platforms. If you will try extracting in Ubuntu, the archive manager will show you the following dialogue box:
This is because the system won’t recognize the file type like Windows and does not have any supported tool to extract it. In other cases, it will also display an error somewhat like this:
Read on below to find out how you can install RAR tools on Linux and use those to open, extract, and compress a file.
How to Install Unrar tool in Linux
Unrar is compatible mostly for Linux distributions where you can easily install the package from the command terminal using the apt programs.
Open Command Terminal and type the following command(s) if you’re using Ubuntu or Debian based distros:
If you are using Fedora distro, type the command in your command prompt:
For users using CentOS/ RHEL 64-bit distros, you can install the Unrar tool using these commands:
$ cd / tmp
$ wget https: // www.rarlab.com / rar / rarlinux-x64- tar.gz
$ tar –zxvf rarlinux-x64-tar.gz
$ cd rar
$ sudo cp –v rar unrar / usr / local / bin /
(Just remove ‘x64’ from the above command if you want to alter it for 32-bit systems)
How to Extract a RAR File in Linux
To open or extract a .rar extension file in your current working directory, type the following command in the terminal:
This will start extracting your file using the Unrar tool like this below:
Note: Since you have the Unrar tool, you can also perform these operations directly through the right click, besides using these commands on the terminal.
To open or extract a .rar extension file in any specific path or directory, type the following command in the terminal. This will extract the files and locate them in the specified directory.
If you want to open or extract a .rar extension file in their original directory, use the following command:
How to View Contents inside a RAR File in Linux
A compressed file contains multiple files of large sizes that are zipped together inside it. If you want to list out all the file contents inside an archive file, use the command below. This will display a list of files with their name, size, time, date created and permissions.
Testing a RAR File in Linux
If for instance, you have downloaded a file from the internet and would like to test its integrity, the Unrar tools offers that too. The following command will do a complete check on the archive file and its contents, and then show the results. Type:
The unrar tool that we just downloaded uses the unrar command to carry out the above tasks. It lets you extract, list out and test files. There is no option for creating a rar file with this particular tool. Therefore, we will install another Linux command-line utility called RAR to create compressed/archive files.
Installing RAR in Linux
To install the RAR command option, type the following commands in the terminal:
After you execute the commands, the result will be:
Creating RAR Files in Linux
In order to create a .rar file in Linux distribution, you will need to run the following command:
This will create an archive file name ‘filename’ for the directory filename1. See how this will look like below:
Deleting Files from any Archive
Out of the multiple files in an archive, if you want to delete a particular file through the command terminal, type the following command:
Recovering deleted Archives
If you deleted an archive file by accident or lost it through data loss, don’t worry, you can always recover it back. The following command will recover the file back or will fix it if there has been any loss or damage.
Setting password on a Particular Archive
This incredible Rar tool lets you do a number of interesting things with your archive files from creating, deleting, and adding, to changing their directories and protecting them through passwords.
If you want to protect your files from unknown access or extraction, you can set a password on them. To password-protect your file, type the following command:
Now, to verify the changes, type the command to open the directory to see if it asks for password.
Wrap Up
RAR and UNRAR are very useful when it comes to handling and managing files in Linux. They provide multiple options to make your work easier and more convenient. When compared to Windows, things get a little complicated for Ubuntu, but these commands are simple, easy to execute and give results within seconds.
If you need more description on the commands, just the run the following two: