7zip File: How to Uncompress 7z files on Ubuntu, Debian, Fedora

by SathiyaMoorthy on April 23, 2010

Question: How do I uncompress a *.7z file ( 7zip file ) in UNIX / Linux ? Can you explain with a simple example?

Answer: Use 7za command to unzip a 7z file ( 7zip file ) on Unix platform as shown below.

Verify whether you have 7za command on your system.

# whereis 7za
7za: /usr/bin/7za /usr/share/man/man1/7za.1.gz

If you don’t have 7za command, install p7zip package as shown below.

Install p7zip to unzip *.7z files on Fedora

# yum install p7zip

Install p7zip to unzip *.7z files on Debian and Ubuntu

$ sudo apt-get install p7zip

Uncompressing a *.7z 7zip files in Linux using 7za

$ 7za e myfiles.7z 

7-Zip (A) 9.04 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-05-30
p7zip Version 9.04 (locale=C,Utf16=off,HugeFiles=on,1 CPU)

Processing archive: ../../myfiles.7z

Extracting  myfiles/test1
Extracting  myfiles/test2
Extracting  myfiles/test
Extracting  myfiles

Everything is Ok

Folders: 1
Files: 3
Size:       7880
Compressed: 404
  • 7za – command name
  • e – specifies the 7z to be extracted
  • myfiles.7z – is the file that is to be extracted

Creating a 7zip compression file in Linux

$ 7za a myfiles.7z myfiles/

7-Zip (A) 9.04 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-05-30
p7zip Version 9.04 (locale=C,Utf16=off,HugeFiles=on,1 CPU)

Creating archive myfiles.7z

Compressing  myfiles/test1
Compressing  myfiles/test2      

Everything is Ok

Files and sub directories of myfiles/ will be added to the myfiles.7z.

  • a – add to archive
  • file.7z – archive file to which these files and dir from dir1 will be added to.

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 15 comments… read them below or add one }

1 Rick Stanley April 23, 2010 at 10:53 am

“7zip File: How to Uncompress 7z files on Ubuntu, Debian, Fedora”

This applies to most Distros of Linux. The only difference is the package installation/update system the Distro uses. A better title would be:

“7zip File: How to Uncompress 7z files on Linux”

2 shiriy April 23, 2010 at 11:49 am

I use 7z command

3 LHammonds October 28, 2011 at 7:26 pm

It is not a good idea to use 7zip by itself to backup and restore *nix files because it will not retain the owner or group for the files. Instead of using it directly, 1st tar the files into a single archive and then compress the tar with 7zip. Example:

tar -cpf – /home/goober | 7za a -si -mx=9 /tmp/myarchive.tar.7z 1>/dev/null 2>&1

4 Ramachandra November 27, 2011 at 4:46 am

$ sudo apt-get install p7zip-full
should be the command to install p7zip to unzip *.7z files on Ubuntu

5 nisar April 6, 2012 at 3:54 am

Thanks for the information. Really helpful

6 white-hat-noob August 8, 2012 at 7:16 pm

Thanks bro, real nice…really helpful

7 Anonymous September 19, 2012 at 1:53 pm

Be very careful … the ‘e’ option actually extracts without any directory structure. The ‘x’ option actually give you the full path when extracted.

8 joe October 12, 2012 at 12:31 pm

needed p7zip-full package, not just p7zip, to get 7za

9 Linux4Ever October 26, 2012 at 12:12 am

Thanks alot , that was helpful .

10 sumpygump October 31, 2012 at 3:26 pm

You should use
7za x instead of the e option.

x will eXtract with the full paths
e will just extract all the files into the same directory, which is probably not what you want.

11 ishitcno1 March 4, 2013 at 11:24 pm

sudo apt-get install p7zip
just gets the 7zr command which only handles 7z archives.
If using 7zr to uncompress a 7z archives, you should use the x option like this:
7zr x myfiles.7z
The x option extract with full paths. If you use e option, all files will extract to the current directory. That’s terrible!

12 Gordon March 10, 2013 at 2:30 pm

You really should be using the x (extract with directories) instead of e (extract everything to this directory, discarding directory info).

13 Alin Dobra May 21, 2013 at 4:23 am

For ubuntu 12.04 :

1. sudo apt-get install p7zip
2. p7zip -d file_name.7z

14 wardevour November 27, 2013 at 2:16 am

very useful, but i think you should point out “7z e file.zip” extracts all the files into the current directory and doesn’t keep the full path. meaning everything in every folder in your archive just got dumped into the current directory. “7z x file.zip” keeps the full paths. “man 7z” is prolly the more useful command for me lol

15 some other guy October 29, 2014 at 8:51 pm

Gordon is right. Use

7za x to maintain the directory structure.

Leave a Comment

Previous post:

Next post: