≡ Menu

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

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)
Scanning

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.
Add your comment

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

Comments on this entry are closed.

  • Rick Stanley April 23, 2010, 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”

  • shiriy April 23, 2010, 11:49 am

    I use 7z command

  • LHammonds October 28, 2011, 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

  • Ramachandra November 27, 2011, 4:46 am

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

  • nisar April 6, 2012, 3:54 am

    Thanks for the information. Really helpful

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

    Thanks bro, real nice…really helpful

  • Anonymous September 19, 2012, 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.

  • joe October 12, 2012, 12:31 pm

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

  • Linux4Ever October 26, 2012, 12:12 am

    Thanks alot , that was helpful .

  • sumpygump October 31, 2012, 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.

  • ishitcno1 March 4, 2013, 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!

  • Gordon March 10, 2013, 2:30 pm

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

  • Alin Dobra May 21, 2013, 4:23 am

    For ubuntu 12.04 :

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

  • wardevour November 27, 2013, 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

  • some other guy October 29, 2014, 8:51 pm

    Gordon is right. Use

    7za x to maintain the directory structure.

  • Akhilesh Kaushik May 10, 2016, 10:50 am

    Correct command is “sudo apt-get install p7zip-full”

  • Wellington June 29, 2016, 9:42 am

    Thanks for Tutorial SathiyaMoorthy.