I have a file called
file.tar.gz. How can I uncompress this
tar.gz file on a Redhat server from the command line? I want all the files extracted in the current directory that I am in. I imagine this would work for Linux or Unix.
- 412.4k times
I have a file called
There is more than one way to do this, however I tend to do it like this from command prompt:
The below does both the uncompressing and untarring in a single command and puts the contents in the same directory you are in:
tar zxvf file.tar.gz
Z argument basically does the gunzip work for you.
Uncompress tar.gz into different directory
-C argument to specify the path to place the files:
tar zxvf file.tar.gz -C /path/to/somedirectory
Uncompress first, untar second
When you uncompress first using gunzip, it will strip the
.gz file extension from the file leaving you with a
gunzip file.tar.gz tar xvf file.tar
You might also encounter a
bz2 file that you need to uncompress and untar:
tar xvjf file.tar.bz2
Common Tar Arguments
With tar some of the arguments we used above mean the following:
x - extract v - verbose output j - filter the archive through bzip2 f - read from a file z - filter the archive through gzip
Hope that helps.
tar -zxvf= ❤️ — AnarchY SI
tar is a compression technology used to create a Tape ARchive. The resulting file is known as a tarball.
If you have Window, this is the same as a Zip file. You use winzip to compress and uncompress .zip files.So its the same idea. To uncompress the files (or to get the files out of a tarball), you can use the following commands in linux.
tar xvf filename.tar
If the tarball has also been gzipped (compressed), you can use the following command:
tar xvfz filename.tar.gz
If you only want certain directories from the tarball, do this:
tar xvzf filename.tar.gz */dir.you.want/*
If you have a .tar.bz2 file, then you need bzip2 installed (/usr/ports/archivers/bzip2), and you issue this command:
tar yxf filename.tar.bz2
0Just a small clarification is that Windows zipped files are in fact a little different from tarballs. A zipped file is compressed, whereas a tarball is just a bunch of files clumped together into one unit not at all compressed. — kc0tma