Linux.com

Feature

Handling RAR and 7-Zip archives in Linux

By Nathan Willis on February 01, 2007 (8:00:00 AM)

Share    Print    Comments   

The RAR and 7-Zip file compression formats originated on Windows, so support for them on Linux is not as automatic as it is for old Unix holdovers like Gzip and TAR. But with the right software, you can handle these compressed files without much trouble.

First, a little background. RAR -- short for Roshal Archive -- is a proprietary file compression format developed by Eugene Roshal. Roshal sells a commercial utility for Windows called WinRAR, but also offers uncompress-only clients for a number of operating systems at no charge.

7-Zip is a Windows application designed to handle as many compression formats as possible. Its native format is 7z, which uses a modern offshoot of the LZ77 compression algorithm. The 7-Zip Windows app and a 7z software development kit are available under the LGPL.

Both formats purport to achieve better compression ratios for common data types than older algorithms. They also support splitting large archives into multiple small volumes for easier mobility and error recovery. The combination of those two features had made them popular choices for online distribution of extremely large files such as ISO images.

7z and Linux

The 7-Zip app is open source, but remains Windows-only. For Linux users, the project links to a command-line client package named p7zip that provides two executables, 7z and 7za. The two have the same syntax and options, differing only in that 7za is a self-contained app compiled only for use with 7z and the essential Unix formats (tar, gzip, bzip2, etc.), while 7z uses a plugin architecture that allows it to support many additional compression formats.

The basic syntax is 7z function options filename.7z. To uncompress an archive, use 7z x myfile.7z . You can extract files from an archive with 7z e myotherfile.7z , but using the e function extracts all files to the current working directory, whereas x preserves their paths.

RAR and Linux

The RAR situation is a bit more complicated, due to the file format's proprietary compression scheme. The RARLAB site provides a no-charge proprietary uncompress-only client for Linux called unrar, designed for 32-bit Intel distros in both RPM and Slackware packages, and as standalone binaries for PowerPC, 64-bit Intel, and ARM Linux systems. Since RARLAB's unrar program is neither free software nor open source, you are unlikely to find it shipping with many Linux distributions. You can download a source code tarball from RARLAB, but the attached license explicitly forbids you from using the source code to develop any form of RAR encoder.

Another option is a GPLv2-licensed command-line tool developed by the Gna! project. Confusingly enough, the open source RAR decoder is also named unrar. Gna! unrar is designed as a wrapper around unrarlib, an open source RAR decoding library developed by Christian Scheurer and Johannes Winkelmann -- who are not part of Gna!.

Scheurer and Winkelmann developed unrarlib from the original RARLAB source code, but asked for and obtained permission from Eugene Roshal to release their work as free software. Thus, unrarlib is available under the GPLv2 and under RARLAB's original proprietary license.

That licensing arrangement would seem to clear a path for interested parties to do an end-run around RARLAB and create a competing RAR encoder from the original source code, but that hasn't happened yet. Scheurer himself isn't interested in pursuing it, saying that he prefers to use open source formats for making archives. "You cannot always choose in what format you get the data, so it is fine to have an open way to access it. But you can choose the way you create an archive. If you don't want closed source compression tools, there are good alternatives."

The proprietary unrar uses the same basic syntax as 7z and 7za. To uncompress and archive and preserve file paths, type unrar x myarchive.rar . In the GPL unrar, you simply add a hyphen before the x: unrar -x myotherarchive.rar .

Today, unrarlib only supports up to version 2 of the RAR file format. Scheurer says he is working on adding support for the newer RAR3 format to unrarlib, but says he is not sure what reaction to expect from RARLAB.

GUI support

If you do most of your work from a Linux window manager, you're in luck. Both GNOME and KDE have graphical archive managers -- File Roller for GNOME and Ark for KDE. Recent versions of both use plugins to support a wide variety of archive formats, and rely on p7zip for 7z support and Gna! unrar for RAR support. Due to the incompatibility of newer RAR3 files, though, you may still need to install the proprietary unrar on your system as well.

As I mentioned at the beginning, both 7z and RAR support splitting large files into smaller chunks. However, in my tests, neither File Roller nor Ark recognized that a directory full of sequentially numbered files myfile.7z.001, myfile.7z.002, myfile.7z.003, and so on constituted one 7z file split into bite-sized chunks.

Thus, to get at the data inside, I needed to rejoin the split files into one on the command line using the cat command. cat myfile.7z.001 myfile.7z.002 myfile.7z.003 > myfile.7z will glue the partial files back together in order, naming the result myfile.7z. At that point, you could open the 7z archive up in File Roller or Ark, but as long as you are already at the command line, it is much quicker just to type 7z x myfile.7z, and voilà -- data, beautiful data, right at your fingertips.

Share    Print    Comments   

Comments

on Handling RAR and 7-Zip archives in Linux

Note: Comments are owned by the poster. We are not responsible for their content.

Click Konqueror

Posted by: Anonymous Coward on February 02, 2007 04:14 AM
Click archive file.

What can be easier?

#

I'm a fan of rar terminal program myself

Posted by: Anonymous Coward on February 02, 2007 04:32 AM
much quicker to type rather than touching the laggy mouse

#

Re:Click Konqueror

Posted by: Anonymous Coward on February 02, 2007 09:14 PM
That's assuming you have the rar extracter installed, which is what TFA explains.

#

Oh for fucks sake

Posted by: Anonymous Coward on February 02, 2007 08:21 AM
More Windows crap on a supposedly Linux/Open Source site.

#

You are being foolish

Posted by: Anonymous Coward on February 03, 2007 02:07 AM
1. The article is about tools that run on Linux to manipulate compression formats for data files. It's not about Windows.

2. Just because the data file formats were originally developed for use on Windows does not mean they are not useful on Linux. The article is not about Windows.

3. Your use of foul language with a foul attitude to match along with a complete ignorance of what the article is about makes you look like a fool.

#

7z nice

Posted by: Anonymous Coward on February 02, 2007 06:48 AM
7z is very nice, it supports AES 256. It has very good compression ratio.
Info about 7z format;
* <a href="http://en.wikipedia.org/wiki/7z" title="wikipedia.org">http://en.wikipedia.org/wiki/7z</a wikipedia.org>

Backup home directory.
$ 7z a backup.7z "/home/foobar"

#

Re:7z nice

Posted by: Anonymous Coward on February 02, 2007 07:14 AM
Yeah, but it ain't as good if you want to compress video and audio files. (Not as efficient as RAR)...I wish it were though, that would be awesome.

#

Re:7z nice

Posted by: Administrator on February 02, 2007 02:34 PM
Flac is great for audio compression.

flac.sf.net

#

XArchiver GUI Support

Posted by: Anonymous Coward on February 02, 2007 07:52 AM
XArchiver <a href="http://xarchiver.xfce.org/" title="xfce.org">http://xarchiver.xfce.org/</a xfce.org>

Though it's for XFCE, it runs like sweet honey on Gnome, KDE, and various Window Managers, it's very nice!

#

*lots* of problems for the rest of us

Posted by: Anonymous Coward on February 02, 2007 05:26 PM
are there, as soon as you move off 7-bit universe centrum and off into 8-bit, multi-charset world.

E.g. to more or less work with RAR archives encapsulating Cyrillic file and directory names, one is limited to e.g. ru_RU.CP1251 locale (which cuts off most GTK2 software, taking into account GTK developers brain damage regarding 8-bit locales and the simple fact that "it's not gonna work" in UTF8 without considerable footwork -- which is not being done with any GUIs I know of).

--
Michael Shigorin
shigorin/gmail

#

Bullshit.

Posted by: Anonymous Coward on February 03, 2007 10:04 PM
Bullshit.

RAR as well as 7zip are both using Unicode to store file names. If you have problems, bring them directory to Eugene Roshal or to Igor Pavlov, authors of rar and 7zip respectively. Checking out gnome & gtk mail lists also make sense.

I'm using both extensively past 3 years and yet to encounter single problem with them - regardless of bunch of names I have: Cyrillic, Central Europe & Japanese' kana & kanji. Though I use them mostly in console.

P.S. It is ZIPs which causes problems, since intl' isn't standartized: WinZip does one thing, InfoZip does something else.

#

Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 02, 2007 06:28 PM

Proprietary format? Legal restrictions? Why would anyone use this garbage?


Somebody stupid enough to use RAR is unlikely to have anything useful to compress with it. I think I can ignore this pile of crap.

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 02, 2007 07:39 PM
You are lucky. Many friends who use Windows send me archives in RAR instead of ZIP format all the time. I don't compress anything to RAR format, for the reasons you mentioned, but I _need_ a way to decompress those archives.

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 02, 2007 09:29 PM
I hate getting files in RAR, for the precise reason of having to cat them all back together (and it being a hassle due to its proprietary format). I often request a different format or tell the sender that I need a CD send with regular data if they cannot send me a Zip.

Send your friends tgz files back perhaps!

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 03, 2007 09:08 AM
Most people who send you stuff in RAR archives has WinRAR installed. WinRAR deals with<nobr> <wbr></nobr>.tgz files without any problems.<nobr> <wbr></nobr>;) Furthermore, I'm not an asshole. I'm not the typical eye-by-eye guy.<nobr> <wbr></nobr>:P

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 05, 2007 10:27 PM
You don't need to cat RARs back together, rar will automatically process all parts. E.g. rar x some_file.rar, will process some_file.r01, r02... rnn. You don't even have to specify the first file, any file from the archive will generate a full extraction.

The real reason people started using RAR is down to USENET binaries having to be posted in multiple parts.

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 05, 2007 09:39 AM
No, you don't. Just have them use WinZip instead. ZIP archives handle file-splitting just fine and have for the last fifteen years.

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 06, 2007 08:43 AM
Yes, you do. Sometimes you simply can't control what other people do. You can ask them politely to use ZIP instead, you can recommend them to install 7zip, but when the moment comes, if they send you a RAR archive because they forgot to use ZIP or because they ignored your petition, you really need a tool to extract the files, specially when you have a deadline coming and can't bother discussing, or they're unreachable at the time you receive the archive.

The reason they use RAR may be that somebody, at some moment, recommended them to use WinRAR or installed WinRAR for them, and that's what they have. Then, they forget or don't know how to select the ZIP format instead of RAR format, or are unaware that the RAR file format is proprietary. It has nothing to do with technical reasons in most cases. Nothing to do with splitting files or the compression level, and many times you have to deal with it and extract the files. Period.

#

Re:Why would ANYONE use RAR?

Posted by: Anonymous Coward on February 06, 2007 09:29 AM
You are lucky. Many friends who use Windows send me archives in RAR

      instead of ZIP format all the time. I don't compress anything to RAR

      format, for the reasons you mentioned, but I _need_ a way to

      decompress those archives.
>
>
Bet ya can't wait to unrar all those archives of tenicale porn, can ya?

#

atool

Posted by: Anonymous Coward on February 02, 2007 10:01 PM
Once you have installed unrar, zip, tar, etc., you may considered install 'atool'. It makes extraction a lot easier:
aunpack yourArchiveRarTarZipOrWhatever

No particular syntax to remember.

#

Just Say No.

Posted by: Anonymous Coward on February 04, 2007 12:37 AM
Just say no to all these splinter formats!
Plain old zip is supported by all platforms including *nix, VMS, MSDOS, OS/2, Windows all, Minix, Atari, Macintosh, OS X, Amiga, Acorn, RISC OS.
Plain old zip has good compression.
Plain old zip has supported splitting into multiple files from day one.

Gaining an additional ~2% compression on certain files is really not that big of a deal, especially when universal compatibility is lost. I see no major advantage in these newer formats that zip hasn't had since 1984.

#

Re:Just Say No.

Posted by: Anonymous Coward on February 04, 2007 02:06 AM
I like the strong encryption option. It's useful for carrying sensitive data around on a USB key. Do any of the other formats offer this? I know that the password protection on "plain old zip" is easily broken.

#

Re:Just Say No.

Posted by: Anonymous Coward on February 05, 2007 09:40 AM
PGP. 'Nuff said. And cross-platform, too.

#

Re:Just Say No.

Posted by: Administrator on February 04, 2007 09:28 AM
I agree with what you are principal but there are cases when you just can't use zip. Specifically, zip seems to handle Unicode inside the files correctly but not in the actual file names. I've had Japanese file names corrupted on me on more than one occasion.

#

There's also an LZMA patch to TAR

Posted by: Administrator on February 03, 2007 01:34 AM
LZMA is the compression algorithm that 7zip uses. One can install lzma-utils and apply a patch to tar that gives it the ability to do like -j does for bzip2

Then you get the benefits of tar and such, with the compression ratios of 7zip's LZMA algorithm<nobr> <wbr></nobr>:)

#

PeaZip on linux

Posted by: Administrator on February 07, 2007 10:53 PM
I recently published on SourceForge this LGPL program:
<a href="http://peazip.sourceforge.net/" title="sourceforge.net">http://peazip.sourceforge.net/</a sourceforge.net>
It's a GUI frontend for p7zip, so allows create/browse/test/extract 7z and to browse/test/extract RAR archives (it also supports tar, zip, volume spanning etc).
Latest version (1.3, published 2007 02 02) supports also PAQ8F and PAQ8JD archives.
The application is statically compiled and only dependency on Linux is for libgdk_pixbuf library, other than that dependency the application can be used as autocontained, portable application, so can be used on different Linux distributions and desktop managers without installation.
I hope it may be useful to spread the use of 7z format on Linux, IMHO 7z is a great format!

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya