Is there a way to extract files of tar.7z format using command line tools in Ubuntu?
3 Answers
Yes - the package p7zip
/ p7zip-full
provides a command-line application to zip/unzip 7z files. The command is simply 7z
.
You can combine a 7z
/ tar
call using a pipe:
7z x -so yourfile.tar.7z | tar xf - -C target_dir
where target_dir is a already-existing directory.
-
15Who ever publishes tar.7z (lzma compression) files should learn about tar.xz/txz (lzma2), since this compression if available for
tar
viaJ
parameter (liketar -cJf
; not to be confused: capital J is for xz, small j is for bzip2) whenxz-tools
package is installed. It's also the default format on kernel.org. Commented Sep 5, 2013 at 11:56 -
People may wish to use 7zip for the strong encryption and multi-volume support.– AaronCommented Jan 26, 2015 at 20:47
-
1I found the answer to my question of why people combine tarballs with 7z. Even though 7z can store trees of files, it apparently does not preserve Unix permissions and metadata, so tarball can be used to preserve that while using 7z. But then, I agree with @LiveWireBT, just use xz, gzip, or bzip2.– bambamsCommented Mar 30, 2017 at 0:01
-
1
-
1@Antonio: The question (an thus, my answer) concerned tar.7z files, not simple .7z archives. If your file isn't a compressed tar archive, of course my cmd line example will fail, since the tar command doesn't find a tar archive to expand. Commented Feb 4, 2018 at 8:01
Install p7zip-full if not already installed:
sudo apt-get install p7zip-full
execute this command to extract .tar.7z file(go to directory where is your file, if
myfile.tar.7z
is your file name):7za x myfile.tar.7z tar -xvf myfile.tar
That's it. Actually first command extracts in .tar file then next command extracts it completely.
Make sure that 7zip is installed, if not, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
sudo apt-get install p7zip
To install the command line utility do:
sudo apt-get install p7zip-full
Once done you can do the following to extract:
7z e <file_name>.tar.7z
To extract with full paths:
7z x <file_name>.tar.7z
To specify a path to extract to:
7z x <file_name>.tar.7z -opath
7z does not allow spaces between -o
and path.
-
6
-
To open a password protected file you can provide -p<your password> as argument. Commented Apr 1, 2018 at 20:56
-
2@Mitch, "To specify a path to extract to:", the path has to be continued with "-o" like "-o/mypath" Commented Apr 23, 2018 at 14:23
-
1Thanks @DineshKumarP, I was not getting put the destination path until sees his explanation saying that "-o" must be along the way "-o/path". Commented Aug 25, 2018 at 14:12
7z x PACKAGE.7z
that should eXtract the packages with full path." How is that not command line?