Tombuntu

Add 7z (7-Zip) File Archive Support to Ubuntu

The 7z (7-Zip) archive format offers good compression ratios and is an open source format. This and the favored 7-Zip graphical file archive tool for Windows have popularized the format.

7z archive

A default Ubuntu installation can’t extract or create 7z files. A package is available in the universe repositories that makes working for these files seamless with Ubuntu’s existing archive tools.

Install 7z file archive support from the package p7zip (click the link to install), or by running the command below in your terminal:

sudo apt-get install p7zip

You can now create 7z archives by right-clicking a file or folder and selecting Create Archive, and selecting the 7z option. Open a 7z archive by double clicking it.

Occasionally I’ll get an E_NOTIMPL error compressing a large number of files using Create Archive. This error should be safe to ignore.

p7zip is easy to use on the command line. To compress a file, mystuff to mystuff.7z:

p7zip mystuff

To decompress the archive:

p7zip -d mystuff.7z

compression comparison graph

I did a quick test of some available compression formats in Ubuntu. I archived 97.9 MB of source code in four formats.

The 7z format clearly compressed the source code far better than other formats, but it took significantly longer to do so.

You may also be interested in adding similar support for RAR archives.

Archived Comments

Anonymous

Did you try with lzma ?
lzma -9 on your .tar may create even smaller archive.

Vadim P.

Oh hm, .bz2 isn’t that much better than .gz.

Could you please do a copression vs time to compress on these algorithms, + rar (for the people that are interested) please?

Bruno Miguel

If I’m not mistaken, 7Zip uses LZMA by default; but I’m not sure.

Steven

Most definitely a useful compression format, has a number of benefits, especially for larger archives. It is by far not used widely enough in the community.

Anonymous

@Bruno Miguel: Yes, 7-Zip uses LZMA but a “.7z” file isn’t the same as a “tar.lzma” one, the latter WILL BE smaller.

Dmitri

LZMA is good, but not *that* good. As a fair comparison:

# tar -cvf linux-2.6.24.tar linux-source-2.6.24

# bzip2 -9kv linux-2.6.24.tar
linux-2.6.24.tar: 5.738:1, 1.394 bits/byte, 82.57% saved, 273940480 in, 47740644 out.

# lzma -9kv linux-2.6.24.tar
linux-2.6.24.tar: 85.81% – encoded succesfully

# ls -al

-rw-r–r– 1 root src 47740644 2008-07-22 10:11 linux-2.6.24.tar.bz2
-rw-r–r– 1 root src 38875477 2008-07-22 10:11 linux-2.6.24.tar.lzma

Your “not implemented” error probably means you’re *excluding* files that are otherwise included in the tarballs.

Aaron

Great Thanks.
So much easier to remember then the untar command.
Thanks,
Aaron

Kagee

7z should not be used for archiving (7-zip does not store the owner/group of the file) but other than that i love it. It’s nice to be able to decompress any file with «7z x filename.extension», and not have to google for how to do it.

Fevrin

Actually, that E_NOTIMPL error is a bug in file-roller that’s apparent when trying to 7z archive any files with a space in their full path. I’ve personally worked around this issue by creating a Nautilus Actions script, but it would be nice for the file-roller developers to get this sorted.

mozz44

after sudo apt-get install p7zip apt downloaded the packages and stuff it needed however I got the following message and still could not open my 7z files:

dpkg: syntax error: unknown group `postdrop’ in statoverride file
E: Sub-process /usr/bin/dpkg returned an error code (2)

Mwaro'z

after sudo apt-get install rar unrar it open rar files via archive manager but while on archive manager i got “An error occurred while loading the archive”

Archive: /tmp/.fr-AoThsV/TestInside, CCNP ONT, v8.07_Setup 176Q.exe
[/tmp/.fr-AoThsV/TestInside, CCNP ONT, v8.07_Setup 176Q.exe]
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
zipinfo: cannot find zipfile directory in one of /tmp/.fr-AoThsV/TestInside, CCNP ONT, v8.07_Setup 176Q.exe or
/tmp/.fr-AoThsV/TestInside, CCNP ONT, v8.07_Setup 176Q.exe.zip, and cannot find /tmp/.fr-AoThsV/TestInside, CCNP ONT, v8.07_Setup 176Q.exe.ZIP, period.

Dennise Meachem

My things to do are suffering as I leaf through your blog.

Bhawar

plz anybody help me i can’t install unrar in my system…

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.38-8 linux-headers-2.6.38-8-generic flex-old
Use ‘apt-get autoremove’ to remove them.
The following NEW packages will be installed:
unrar
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 107 kB of archives.
After this operation, 266 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ natty/multiverse unrar i386 1:4.0.3-1 [107 kB]
Fetched 107 kB in 6s (15.4 kB/s)
Selecting previously deselected package unrar.
(Reading database … 166355 files and directories currently installed.)
Unpacking unrar (from …/unrar_1%3a4.0.3-1_i386.deb) …
Processing triggers for man-db …
Setting up samba (2:3.5.8~dfsg-1ubuntu2.3) …
start: Job failed to start
invoke-rc.d: initscript nmbd, action “start” failed.
dpkg: error processing samba (–configure):
subprocess installed post-installation script returned error exit status 1
Setting up unrar (1:4.0.3-1) …
update-alternatives: using /usr/bin/unrar-nonfree to provide /usr/bin/unrar (unrar) in auto mode.
Errors were encountered while processing:
samba
E: Sub-process /usr/bin/dpkg returned an error code (1)
mahipal@ubuntu:~$ sudo apt-get install unrar
sudo: /var/lib/sudo writable by non-owner (040777), should be mode 0700
[sudo] password for mahipal:
Reading package lists… Done
Building dependency tree
Reading state information… Done
unrar is already the newest version.
The following packages were automatically installed and are no longer required:
linux-headers-2.6.38-8 linux-headers-2.6.38-8-generic flex-old
Use ‘apt-get autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up samba (2:3.5.8~dfsg-1ubuntu2.3) …
start: Job failed to start
invoke-rc.d: initscript nmbd, action “start” failed.
dpkg: error processing samba (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
samba
E: Sub-process /usr/bin/dpkg returned an error code (1)

Mike

Personnally, I was getting E_NOTIMPL errors because I wasn’t using p7zip-full. p7zip is a lightweight version that isn’t supporting encrypted 7zip file compression.

Respond via email