How can I extract a *.7z file on Ubuntu while keeping the directory structure intact?

Following this guide, I tried

7za e My.7z file.

But it does not keep the files in the SAME directory structure whith all the files at the parent directory.

Thank you.

  • Please include an example showing what you would like to get and what is actually happening. Also, you have probably created the archive badly, make sure you compress the parent folder and not its contents, ie run 7za -a foo.7z /foo and NOT 7za foo.7z -a /foo/*.
    – terdon
    Dec 19, 2012 at 20:48

1 Answer 1


Maybe this can help you:

7z x Myfile.7z
  • 4
    Yes, always use "x" to keep directory structures! Note that if you use the tag "e" f.eg 7z e Myfile.7z it will pile up all the FILES into your cwd without any directory. I experienced messing up all my existing files!
    – MathArt
    Nov 26, 2020 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .