How to Unzip Tgz File on Linux Quickly

0
Unzip Tgz File on Linux

The tar command on Linux is used to create .tar.gz or .tgz archive files. Most of the Linux files are distributed in .tgz or tar.gz. In this short tutorial, you will learn how to (extract) or unzip tgz file on Linux from the command line.

Unzip Tgz file on Linux from Command Line

To extract a .tgz file with tar, use following command.

$ tar -xvzf /path/to/yourfile.tgz

Command details

  • tar – tar command will auto-detect compression type.
  • x – to extract the file.
  • v – v stands for verbose, it will show output.
  • f – f represents the file for extraction.
How to Unzip Tgz File on Linux Quickly Click To Tweet

Extract Specific Files and Directories from the Tgz file

To extract specific files, use following command.

$ tar -xf /path/to/yourfile.tgz file1 file2

To extract specific directories, use following command.

$ tar -xf /path/to/yourfile.tgz directory_1 directory_2

Extract a .tgz file in different directory

You can extract tgz file in different directories using -C in between to path/location.

$ tar -xvzf /path/to/yourfile.tgz -C /path/where/to/extract/

Conclusion

In this article, you have learned to extract or unzip tgz file on Linux. If you have any doubt, feel free to comment below. Also, you can join our elite Facebook group to get direct help from me. If you like this article, please share this article on your social media handle.

LEAVE A REPLY

Please enter your comment!
Please enter your name here