Linux How To Open / Extract tar.gz
Opening or extracting a tar.gz file is very easy on Linux.
Extract a tar.gz file using a single command:
tar xvfz example.tar.gz
These are the parameters that we used.
x | extract |
v | verbose output |
f | operate on a file |
z | gunzip it first |
Extract the file using two separate commands. First gunzip and then unpack the tar file.
gunzip example.tar.gz
tar xvf example.tar
You can also specify a directory that you want to extract to like this:
tar -xf example.tar.gz -C /home/user1/dir1
You can choose to only extract specific files if you want:
tar -xf example.tar.gz test1 test2
If you just want to see the contents of the file use this command:
tar -tvf example.tar.gz