extract a .tar.gz file

1
tar -xvzf test.tar.gz

tar collected all the files into one package test.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:

  • f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.
  • z: tells tar to decompress the archive using gzip
  • x: tar can collect files or extract them. x does the latter.
  • v: makes tar talk a lot. Verbose output shows you all the files being extracted.

To extract into a custom folder, add the -C option with a folder name of your choice:

1
tar -xvzf test.tar.gz -C some_custom_folder_name

reference

Licensed under CC BY-NC-SA 4.0
Last updated on Nov 16, 2024 11:38 +0800