HomeLinuxCreate and Extract TAR.GZ Recordsdata on Ubuntu 22.04?

Create and Extract TAR.GZ Recordsdata on Ubuntu 22.04?


The zipped/compressed information are useful for lowering the dimensions of assorted information and safe information transmission. Essentially the most used compression format in Linux is “tar.gz”, which shops a number of information in a single archive. To work together with the “tar.gz” information, the compression and decompression are the 2 keys The “tar.gz” information compression and decompression are dealt with by means of the Linux built-in “tar” command.

This publish illustrates the whole course of to create and extract “tar.gz” information on Ubuntu 22.04 with the next outcomes:

Create TAR.GZ Recordsdata on Ubuntu 22.04?

The “tar” command line device handles quite a lot of compression codecs akin to “. xz”, “gz”, “.tbz”, “.bz2”, and so forth. This part includes the “tar” command used to create the “tar.gz” information on Ubuntu 22.04.

Syntax:
The generalized syntax to create a “tar.gz” file is written right here:

$ tar czf [file_name.tar]

The syntax defines the next parameters:

  • tar: Represents the “tar” command line utility.
  • c: Creates the required tar file.
  • f: Specifies the archive file identify.
  • z: Creates and extracts compressed information utilizing “gzip”.
  • file_name.tar: Identifies the compressed tar archive.

There are 4 information out there within the “Pattern” listing as proven beneath:

Instance: Create a tar of A number of Recordsdata
Create the “New.tar.gz” compressed tar archive of those 4 information utilizing the above “tar” command syntax on this manner:

$ tar czf New.tar.gz File1.txt File2.txt File3.txt File4.txt

The “New.tar.gz” has been efficiently created within the “Pattern” listing.

Extract TAR.GZ Recordsdata on Ubuntu 22.04?

The “tar” command is a useful device that may extract the “tar.gz” information into the present working listing or the listing.

Syntax:
The essential syntax to extract/unzip the “tar.gz” information is typed right here:

$ tar xzf [file_name.tar]

The “x” flag is used for the extraction of compressed information.

Instance 1: Extract “tar.gz” Recordsdata in PWD
To extract the “tar.gz” file, merely make the most of the above syntax with the created compressed “New.tar.gz” file within the terminal:

All of the compressed information have been extracted into the “Pattern” listing.

Instance 2: Extract “tar.gz” Recordsdata in Explicit Listing
The “-C(–listing)” flag helps the customers to extract the “tar.gz” information into the listing the place he needs.

On this situation, the “New.tar.gz” compressed archive positioned within the “Pattern” is extracted into the “Downloads” listing utilizing the “tar” command on this manner:

$ tar xzf New.tar.gz -C /residence/linuxhint/Downloads/

Let’s confirm it utilizing the “ls(checklist)” command adopted by the “Downloads” listing:

The output confirms that “New.tar.gz” has been extracted into the “Downloads” listing.

Instance 3: Extract Particular File From “tar.gz”
Easy sort the identify of the required file that you just wish to extract from “tar.gz” information with the “tar” utility within the following manner:

$ tar xzvf New.tar.gz File2.txt

The “File2.txt” has been extracted from the “New.tar.gz” compressed file.

Conclusion

In Ubuntu 22.04, the pre-installed “tar” command utility helps the compression and decompression operation of “tar.gz” compressed information. This command makes use of its supported choice to carry out the specified job counting on their names. This publish has listed a set of examples that display the creation and deletion of tar.gz information in Linux.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments