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.
Comments on this entry are closed.
“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”
I use 7z command
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
$ sudo apt-get install p7zip-full
should be the command to install p7zip to unzip *.7z files on Ubuntu
Thanks for the information. Really helpful
Thanks bro, real nice…really helpful
Be very careful … the ‘e’ option actually extracts without any directory structure. The ‘x’ option actually give you the full path when extracted.
needed p7zip-full package, not just p7zip, to get 7za
Thanks alot , that was helpful .
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.
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!
You really should be using the x (extract with directories) instead of e (extract everything to this directory, discarding directory info).
For ubuntu 12.04 :
1. sudo apt-get install p7zip
2. p7zip -d file_name.7z
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
Gordon is right. Use
7za x to maintain the directory structure.
Correct command is “sudo apt-get install p7zip-full”
Thanks for Tutorial SathiyaMoorthy.