How can I uncompress a *.7z file?

How can I uncompress a *.7z file in Ubuntu and keep the directory structure?

Asked By: michael


First install the p7zip-full package:

sudo apt-get install p7zip-full

With this, Nautilus should have an option to uncompress 7-Zip Files.

I also recommend p7zip-rar so it also includes support for RAR files.

This is assuming you want to do it via GUI with Nautilus. If not, after downloading the packages above do the following:

7z x PACKAGE.7z 

that should eXtract the packages with full path.

Answered By: Luis Alvarado

Run following command in the terminal:

sudo apt-get install p7zip-full p7zip-rar

Or search through the ubuntu software center as 7zip and unrar and install the packages.

Answered By: user89707

There is also dtrx – which is immensely useful for un-archiving anything.

it stands for "Do The Right eXtraction" – and will uncompress anything without any fuss.


sudo apt-get install dtrx
dtrx archive.tar.XX


UPDATE for Ubuntu 20.04 :

According to their pypi page, dtrx is not currently available in the official repos. Thus, if you cannot install this via apt, then you can still use pip3:

pip3 install dtrx

If you don’t already have pip3 installed, you can install it with

sudo apt install python3-pip
Answered By: rm-vanda

For ubuntu 17.04, no need for the full package, p7zip is enough:

sudo apt install p7zip

Then, uncompress using the -d command:

p7zip -d something.7z
Answered By: Derlin

The other answers did not work for me.

But this command worked fine:

7z e file.7z
Answered By: Soroosh Sorkhani

First install the according package
sudo apt install p7zip-full

  • use x flag to extract files with full path
  • use -o flag to set output directory

7z x <archive_name> -o{Directory}

for example

7z x file.7z -o/home/michael/Documents/NewFolder

Notice that there is no space between -o and the output directory. If the file was encrypted, it will automatically ask for the password.

Answered By: Anno

here is unarchiver

sudo apt install unar


unar xxx.7z

that’s it.

Answered By: AsukaMinato

To extract all 7z archives into their own folder, using the archive name as the folder name:

7z x "*.7z" -o*

E.g., if one has the two files a.7z and b.7z, then folders a and b will be created and they’ll contain the content of a.7z and b.7z (keeping the directory structure), respectively.

Answered By: Franck Dernoncourt

In 2024 I think the easiest option is to use the Linux version of 7-zip.

This provides an official tool which does not require any installation. The executable 7zzs can be used out of the box and is portable. It also seems to have the same syntax as p7zip (at least for simple stuff). E.g. 7zzs x archive.7z to extract. (Add it to your $PATH in order for 7zzs to work or use the full path e.g. /directory/containing/the/executable/7zzs)

Also possibly of interest: Difference between several command-line tools provided for 7-Zip compression (like `7z`, `7zz`…)

Answered By: Kvothe
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.