Create and extract tar.gz file using tar tool in Linux

When working with Linux system, we usually work with the tar.gz files using tar tool. So that, we need to know how we can create and extract them. In this tutorial, I will show you how to create and extract tar.gz file using tar tool in Linux.

First of all, we need to know some commonly used options of tar tool:

  • c: Create new tar file.
  • v: Display the files will be compressed or extracted in command.
  • f: Create new tar file with the file name in the command.
  • z: Using gzip to zip the file.
  • x: Extract the tar.gz file.

Now, to create a tar.gz file from a given file or folder, we can use tar tool with the following command:

This will compress the contents of <source-name> into a tar.gz archive named <tar-archive-name.tar.gz>.

And to extract a tar.gz compressed archive file, we can use the following command:

The command will extract the <tar-archive-name.tar.gz> to the folder named <tar-archive-name>.

Add Comment