Extract 7z files with standard linux tools?

29

5

I know that you can extract .7z files with 7-zip.

Is there another standard linux program that can do this? Maybe one of these

tar
bzip2
xz
gzip

I will add that bsdtar can do this, but is not available on all systems.

Steven Penny

Posted 2012-03-31T04:47:38.033

Reputation: 7 294

http://askubuntu.com/questions/219392/how-can-i-uncompress-a-7z-file – Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-10-07T10:45:11.563

similar question : 7zip for linux

– Santosh Kumar – 2012-03-31T12:38:16.490

Answers

9

No. 7-Zip archives use LZMA and LZMA2, which are not supported by standard tools (they also use bzip2, but you still need to decode the header).

Ignacio Vazquez-Abrams

Posted 2012-03-31T04:47:38.033

Reputation: 100 516

1Actually, xz uses LZMA as well. But yes, it still won't understand the rest of the 7z format. – jjlin – 2012-03-31T05:32:33.140

30

7-zip archives can be extracted with p7zip (http://p7zip.sourceforge.net/) on Linux. It is included in the repositories of: Debian, Fedora, Ubuntu and possibly other distributions too.

List contents with (lower case L, for list):

7za l myarchive.7z

Extract contents:

7za x myarchive.7z

Mike Fleetwood

Posted 2012-03-31T04:47:38.033

Reputation: 409

2on 64 bit RHEL 6, yum install p7zip.x86_64, and, if needed, yum install p7zip-plugins.x86_64 – rivu – 2014-09-09T20:52:54.837

1p7zip is available in macports, as a binary. Just: sudo port install p7zip – smci – 2014-05-07T16:49:24.280

2

The "standard" way to work with 7-Zip archives on Unix is to use P7ZIP. But since the 7-Zip format was designed primarily for Windows, you shouldn't really expect P7ZIP to come installed on Linux distributions by default.

If you want the benefit of LZMA compression on Unix, prefer XZ Utils.

jjlin

Posted 2012-03-31T04:47:38.033

Reputation: 12 964

1

I've could not find 7za in any yum repositories on RHEL/CentOS, so I've just downloaded the latest version of source from sourceforge.net:

$ wget https://sourceforge.net/projects/p7zip/files/p7zip/16.02/p7zip_16.02_src_all.tar.bz2

(change "16.02" above to whatever latest version at time when you try to download, you can find out by going to https://sourceforge.net/projects/p7zip/files/p7zip/ ).

Being in the directory where you downloaded p7zip archive, unpack it:

$ tar -xvjf p7zip_16.02_src_all.tar.bz2

Then run make command as root user inside of extracted folder:

# make
# make install

It'll produce 7za binary in /usr/local/bin directory (if you use RHEL7 at least):

$ whereis 7za
7za: /usr/local/bin/7za

Tagar

Posted 2012-03-31T04:47:38.033

Reputation: 210

0

7za binary is part of p7zip package could be used for that. It could be installed from epel repository if you use RHEL/OL/CentOS (tested on RHEL6/RHEL7):

RHEL6, 7:

# rpm -Uvh http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
# yum install p7zip

This package have not been updated for a long time, but still could be used to extract files:

$ 7za x xyz_7zfile.7z

Gryu

Posted 2012-03-31T04:47:38.033

Reputation: 174

0

I tried 7za at first go but it did not work, so I tried using 7z with same options and it works. Here is the example: To Extract: 7z e xy213file.7z

Avinash

Posted 2012-03-31T04:47:38.033

Reputation: 9

-1

Package p7zip is available in macports, as a binary.

Just: sudo port install p7zip

And you're away! 7z x downloads/myfile.7z

Same goes for CentOS but using yum:

sudo yum install p7zip

smci

Posted 2012-03-31T04:47:38.033

Reputation: 233