UNIX / Linux Decompress tgz / tar.gz and extract files

https://‮al.www‬utturi.com
UNIX / Linux Decompress tgz / tar.gz and extract files

To decompress a .tgz or .tar.gz file and extract its contents on a Unix-like system, you can use the tar command.

Here's the basic syntax:

tar -xzvf file.tar.gz

This will extract the contents of the file.tar.gz archive into the current directory. The options used are:

  • x: Extract the contents of the archive
  • z: Decompress the archive using gzip
  • v: Display progress in the terminal while extracting the files
  • f: Specify the name of the archive file

If you want to extract the files to a specific directory, you can use the -C option followed by the destination directory:

tar -xzvf file.tar.gz -C /path/to/destination/directory

You can also extract .tar archives (uncompressed tar files) using the same command, just omit the z option:

tar -xvf file.tar
Created Time:2017-10-30 14:27:22  Author:lautturi