how to extract tar.7z files from command line?
Solution 1
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.
Solution 2
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.
Solution 3
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.
Related videos on Youtube
pacodelumberg
Updated on September 18, 2022Comments
-
pacodelumberg over 1 year
Is there a way to extract files of tar.7z format using command line tools in Ubuntu?
-
Admin over 10 yearsyes it does @guntbert See the accepted answer "
7z x PACKAGE.7z
that should eXtract the packages with full path." How is that not command line? -
Admin over 10 yearsSorry, but the question is not a duplicate. It asks for handling tar.7z files. Neither the previous question nor its answers cover this matter. Since the answers don't address this question fully, it was legitimate to pose the question here.
-
Admin over 10 yearsYes I also agree, the point of the question is the extraction of the files with a tar.7z format.
-
Admin over 10 years@Rinzwind: Please give some time before marking any post as duplicate. Since you marked it first, all copied your action. This question is for extracting .tar.7z not .7z !! I guess you know the difference.. :)
-
Admin over 10 years@SauravKumar they are exactly the same.Linux does not care about suffixes and an extraction is based on the 1st bytes of the file. It is an identical question. And I trust stephen, andrea, guntbert enough to PM me in chat when I mess up (I have lots of examples of that :D )
-
Admin about 6 years
man tar
mentions--format=v7
, but unfortunately that's only for creating such files, not for extracting from them.
-
-
Csabi Vidó over 10 yearsWho 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. -
nwgat over 9 years
7z x ghost.7z -o/home/node/
to extract to /home/node/ghost -
bambams about 7 yearsI 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.
-
Pavin Joseph over 6 years7z appears to be better for lots of smaller files.
-
Antonio over 6 yearsThe cmd. line proposed here is not working
$ sudo 7z x -so Prime95/p95v294b7.linux64 | tar xf - -C /usr/local/bin/
gave meError: can't decompress folder tar: This does not look like a tar archive
The working cmd. is$ sudo 7z x Prime95/p95v294b7.linux64.7z -o/usr/local/bin/
using the option from the bash cmd. 7zhttp://manpages.ubuntu.com/manpages/xenial/en/man1/7z.1.html
-
tohuwawohu over 6 years@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.
-
Soumendra about 6 yearsTo open a password protected file you can provide -p<your password> as argument.
-
Dinesh Kumar P about 6 years@Mitch, "To specify a path to extract to:", the path has to be continued with "-o" like "-o/mypath"
-
Richard Willian over 5 yearsThanks @DineshKumarP, I was not getting put the destination path until sees his explanation saying that "-o" must be along the way "-o/path".