I have a file called file.tar.gz. How can I uncompress this file on a Redhat server from command line? I want all the files extracted the the current directory that I am in. I imagine this would work for Linux or Unix.
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
The z argument basically does the gunzip work for you.
Uncompress tar.gz into different directory
Use the -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 .tar file:
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 = <3
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
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.
And Windows zipped files are 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.