p7zip is the Unix command-line port of 7-Zip, which has many supported formats. p7zip supports RAR format for unpacking or extract only. User can either download the binaries and source code or install the packages provided by Linux distributions and other supported systems.
With the binaries and source code, p7zip is available in a single download file that can handle all supported formats and installation is optional. That means the command-line tool can be run as soon as the download file (tar.bz2) is extracted by a native archive manager on Linux.
With the packages, p7zip will require separate packages to handle all supported formats and installation is necessary. For Debian (and Ubuntu), p7zip is available in three different packages from the repositories. Ensure that the main and non-free respositories (or universe and multiverse repositories for Ubuntu) are enabled and updated first.
Install the required package 'p7zip-rar' that will additionally include 'p7zip-full' as one of the package dependencies; the other package 'p7zip' is not required at all.
sudo apt-get install p7zip-rar
Then run the 7z command to extract the RAR file.
7z x filename.rar
Short explanation: p7zip provides 7zr
command that can only handle 7z archives. p7zip-full provides 7z
command that can handle more supported formats and p7zip-rar is required for 7z
to handle RAR archives.
Note the following use cases:
7zr
and 7za
commands will not work and only 7z
command will work with the RAR format. p7zip on ArchWiki has noted the difference between 7z, 7za and 7zr binaries.
7z
can be used with any of the supported graphical file archivers, including file-roller, ark, xarchiver, engrampa. Just install one of the supported archive managers to use p7zip via graphical interface, and no further configuration is needed.
- Newer version of RAR files (notably RAR version 5) should be unpacked or extracted using a newer version of p7zip (at least 16.02), otherwise p7zip will return error and failed to open the file.
Example output of p7zip (9.20) failed to test open a RAR file (Rar5):
$ 7z t sample.rar
7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)
Processing archive: sample.rar
Error: Can not open file as archive
Example output of p7zip (16.02) successfully test open a RAR file (Rar5):
$ p7zip_16.02/bin/7z t sample.rar
7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,32 bits,1 CPU Intel(R) Celeron(R) M processor 1.60GHz (6D8),ASM)
Scanning the drive for archives:
1 file, 483579957 bytes (462 MiB)
Testing archive: sample.rar
Path = sample.rar
Type = Rar5
Physical Size = 483579957
Solid = -
Blocks = 5
Encrypted = -
Multivolume = -
Volumes = 1
Everything is Ok
Files: 5
Size: 498584235
Compressed: 483579957
The latter output of p7zip (16.02) had included the line Type = Rar5
that indicates the RAR version 5. The file
command may contain similar but less human readable information of RAR version.
$ file *.rar
sample4.rar: RAR archive data, v1d, os: Unix
sample.rar: RAR archive data, va6, flags: Archive volume, Commented, Locked, os: Unix
Notice that the older RAR file (Rar) by default had included v1d
whilst the newer RAR file (Rar5) had included va6
within the description of each file. To this answered date, no relevant information to determine whether the file descriptions correspond to the RAR versions or not.
TL;DR p7zip can open RAR files, provided the package (p7zip-rar), the command (7z), and the newer version (16.02+ for Rar5 support) are used to handle the RAR format.
Answerer's note: This self-answer--some 18 months later--will be accepted and made as community wiki. Anyone with minimum reputation may edit to make this answer more complete, should there be any missing information.