6

Long explanation ahead to understand the issue before making the decision.

I was trying to recall how to open a random RAR file using p7zip command-line tool on Linux. After looking at some dated discussions on forum thread (lost citation due to private browsing), I managed to recall how I used p7zip to open RAR file last time. Problem solved, except for one misleading answer on Unix SE.

Earlier, I found this post on Unix SE: How to open rar file in linux? There are 9 answers posted under the question to this date, but most answers noted unrar in different ways and only this answer mentioned about p7zip. Despite the answer had +5/-0 votes and one comment noted "it worked", the answer is actually misleading as follows.

sudo apt-get install p7zip
7zr x myfile.rar

On Windows I rely on 7zip for rar and every other archive file, and it works on Linux, too.

There are two apparent issues in the quoted answer.

First: The APT command to install p7zip package on Debian/Ubuntu does not include the required package to successfully open a RAR file. p7zip will suggest p7zip-full, which will finally suggest the required package p7zip-rar. Then again, suggested packages will not be installed unless using --install-suggests option.

The manual page 7z(1) has noted the requirement, as per added bold text:

7-Zip is a file archiver supporting 7z (that implements LZMA compression algorithm featuring very high compression ratio), LZMA2, XZ, ZIP, Zip64, CAB, RAR (if the non-free p7zip-rar package is installed), ARJ, GZIP, BZIP2, TAR, CPIO, RPM, ISO, most filesystem images and DEB formats. Compression ratio in the new 7z format is 30-50% better than ratio in ZIP format.

Second: The subsequent command 7zr from p7zip package does not work with a RAR file.

From the sibling manual page 7zr(1), as per added bold text:

7zr is a stand-alone executable. 7zr is a "light-version" of 7za(1). 7zr handles password-less archives in the 7z, LZMA2, and XZ formats only.

From p7zip on ArchWiki, the difference between 7z, 7za and 7zr binaries has been noted as well.

The package includes three binaries, /usr/bin/7z, /usr/bin/7za, and /usr/bin/7zr. Their manual pages explain the differences:

  • 7z(1) uses plugins to handle archives.
  • 7za(1) is a stand-alone executable that handles fewer archive formats than 7z.
  • 7zr(1) is a stand-alone executable. It is a "light-version" of 7za that only handles 7z archives. In contrast to 7za, it cannot handle encrypted archives.

Therefore, the only command that works with RAR files is 7z and neither of other two. That is indeed true and I have tested by myself. But that is not all and there is a third, hidden issue.

Hidden issue: RAR format has version compatibility issue, in which the RAR tool version and the RAR file version must be matching or supported. For example, if the RAR file was created by a newer RAR tool version 5, then the created RAR file can not be opened by the older RAR tool version 3. This issue can be reproduced with the newer and older versions of p7zip similarly.

Based on the long explanation above, I thought of writing a new answer that will explain to install the correct package, to use the correct command, and to use the correct version and perhaps with actual command output as proof. That seems easier to do without having to worry whether the suggested edit is appropriate or not, since that will result in much different answer from the original.

Then again, there are already 9 answers posted under the question and a new answer will increase that to a two-digit number. That may give a false impression that there are too many similar answers and I may be seen adding more noise under the question.

Finally, here is my meta question:

Should I write a new answer for p7zip to open RAR file, or should I just downvote the answer and leave a comment so that more experienced user can do something about it?

P.S.: By the time I finish put information in order and wrote this meta question, it was late hour and lately I am lacking sleep. I will follow up this again after few days or so.

10

Since you have a question that's slightly more specific than How to open rar file in linux?, my suggestion would be open your own Question with a self-Answer. You could provide a link back to the general "rar" question if you thought it'd be helpful. In your own question, explain what you're trying to do and what the initial problem(s) were. Then Answer your question with the (excellent!) research you've done. I'd recommend using both the and the tags for your question.

A new answer on the existing question would be second-best, in my opinion. You would show the extra steps required to use p7zip to do the job; it would be acceptable, in my opinion, as an Answer to that question, though.

A similar option would be to edit the existing p7zip answer to include the steps that you needed to take. Do take note of the 5 up-votes and one "this worked for me" comment, so I would take care not to clobber the existing answer, but rather append something like "if you run into this or that, do this".

I would not recommend downvoting an answer just because it didn't work for your situation; I would only downvote an answer that wasn't useful for the question it addressed.

  • +1 I haven't thought of the first suggestion; I will probably create the self-answer post and link back under this meta answer when I did. – clearkimura Jun 5 at 1:42
  • 2
    Clarification: The quoted existing answer is not just "didn't work for [my] situation", but essentially will not work for anyone, as per the manpages and the wiki. I will just ignore the misleading answer, as to not escalate this matter. – clearkimura Jun 5 at 1:49
  • Link here if you like, but self-answered questions are not that unusual. Just be sure to write the question up as normal, as if anyone else could answer it -- someone else might! – Jeff Schaller Jun 5 at 1:51
  • I have created the self-answer post as suggested and the meta question is now solved. This meta answer will be accepted. – clearkimura Jun 5 at 3:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .