Software packages are available to download in the form of compressed archives from the software developer’s website. These archives are extracted before the installation process. There are many compressed archives like .deb, .rpm, tar.gz, etc. among which, tar.gz is widely used for software distribution. The compression and extraction of tar.gz archives is supported by the command line tool tar in Linux/Ubuntu.
This article will discuss different scenarios of extracting the tar.gz archive on Linux/Ubuntu 22.04 LTS systems.
The “tar.gz” is a compressed archive file format for Linux systems that uses the “gzip” compression algorithm. “.tar.gz” archives can be created by How to Create a Tar File in Linux/Ubuntu?
The archive “Archive.tar.gz” can be extracted in the same directory by the following command:
The above command comprises of:
We can verify the extraction of the “archive.tar.gz” archive by:
The above image shows that archive.tar.gz is successfully extracted to the “SampleDirectory1” directory.
If we would like to extract the “archive.tar.gz” archive in a specific directory, i.e., in the “Others” directory inside the “Downloads” directory, we can run the following command:
The above command comprises of:
We can verify the extraction of the “archive.tar.gz” archive by navigating to the specified path:
$ ls -l
The above image shows that archive.tar.gz is successfully extracted to the “Others” directory (home/linuxuser/Downloads/Others) from the “SampleDirector1” directory.
There can be situations where all the files compressed in the archive are not required and only a file or few files are required. “Tar” allows the extraction of a file or a few files. The following command will extract only File3.txt and File5.txt from archive.tar.gz:
In the above command, the v flag indicates verbose output.
We can verify the extraction of specific files of the “archive.tar.gz” archive by:
The above image shows that only File3.txt and File5.txt are successfully extracted to the “SampleDirectory1” directory.
Tar.gz archives are extracted using the tar command line tool in either the current working directory or in a specific directory by using the “tar xzf ” and “tar xzf -C ” commands respectively. Additionally, specific files can be extracted from the archive by running “tar xzvf ”. This article discussed different scenarios of extracting the tar.gz archive on Linux/Ubuntu 22.04 LTS systems.
2024 was the GenAI year. With new and more performant LLMs and a higher number…
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…