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


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.

|improve this answer|||||
  • I try to install 7zip-full using apt. I get this message: "Package p7zip-full is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source." – posfan12 Oct 27 '18 at 0:12
  • Note that if the compressed file is VERY large, it will be broken up into separate component files file.7z.001, file.7z.002, etc. However, only the first file, file.7z.001, will show as an decompressable icon on the Nautilus desktop. The others appear as data file icons. Double-click this .7z.001 file to decompress ALL components in the package. Also, apparently all of the .00x component files created during the compression have to be present, or else probably the .001 decompression will fail. – DragonLord Jun 21 '19 at 19:43

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

Manpage: http://manpages.ubuntu.com/manpages/trusty/en/man1/dtrx.1.html

|improve this answer|||||

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.

|improve this answer|||||

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
|improve this answer|||||
  • 1
    p7zip -d --keep something.7z or it will destroy your input file !!!! – Dave Kimble Aug 4 '18 at 7:16
  • This does not extract all files, due to features missing. in my case password protection. Thus this might be misleading. – scones Sep 25 '18 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.