Unzip (decompress) and extract files from a .tar.gz file
Run:
$ tar -xvzf file.tar.gz
First a reminder:
why do we end up with a
.tar.gz
file?
tar
collects multiple files to create one single file. Then, we use gzip
to compress that single .tar
file into a .gz
file, thus the compound .tar.gz
extension.
So to reverse the process, we first need to decompress file.tar.gz
using gzip, and then extract the files from the remaining file.tar
.
What do the options we pass mean?
z
tells tar to decompress the file using gzipx
extracts all files from the.tar
file.f
tells tar the path and name of the file to decompress and extract; this must be the last flag of the command, and the.tar.gz
file must come right after.v
makes tar list all the files being extracted in the terminal as the command runs
To extract into a specific folder, pass the -C option to the command followed by the name of the folder where you want tar to extract the files:
$ tar -xvzf file.tar.gz -C folder
personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki tar