You may have heard about the files or folders compression. Within Windows, the compressed file is said to be the “zip” file. The compressed file is converted into a “tar.gz” extension within Linux or Unix-like systems. You have performed the unzipping of a whole “zip” file on GUI. Have you ever tried to extract one single file from the “tar” file? If not, and you are looking for the extraction of a single file from the “tar” in Linux, then this article is meant for you.

Let’s get started by updating our system first. For this, we will be using the “update” command with the utilization of the “apt” package on the shell instruction area. Make sure to use the sudo rights. The password for the sudo account will be asked after the execution. Write your password and press the Enter key to continue. The system will get updated in a few seconds. The command and its processing are shown below. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image1-11.png" data-lazy- height="56" src="data:image/svg xml,” width=”526″>

After the system has been updated, you may upgrade your system in some cases. Try out the “apt” command followed by the “upgrade” keyword along with the utilization of “sudo” rights. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image3-8.png" data-lazy- height="73" src="data:image/svg xml,” width=”399″>

This process will start by asking you to make sure that you want to upgrade your system. It will show you the memory space required to complete this upgrade process. Tap “Y” to continue the process in no more than seconds.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image2-9.png" data-lazy- height="39" src="data:image/svg xml,” width=”606″>

The process will be started, and system utilities will be upgraded. Your system and its packages will be upgraded.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image5-7.png" data-lazy- height="20" src="data:image/svg xml,” width=”714″>

Now, it’s time to download some tar zip files on our Ubuntu 20.04 system. Without any tar zip file, we will not be able to perform our article. We want to download a cmake application “tar” file on our Downloads folder. We use the web path for the “tar” file to be downloaded. This path will be used on the shell within the “wget” command to download it. Use the sudo rights to download this “tar” file, as shown in the attached photo. The Ubuntu 20.04 system has started to get information regarding the “cmake” tar file from its website. After the information gathering, it will start downloading. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image4-7.png" data-lazy- height="72" src="data:image/svg xml,” width=”715″>

The system will start downloading your cmake tar file as per the below processing output. It will probably take 5 minutes to complete the download process. So, sit back and relax.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image7-5.png" data-lazy- height="22" src="data:image/svg xml,” width=”703″>

The processing bar as “100%” in the below image will show you that the file has been successfully downloaded. You can find your tar file in the Downloads directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image6-7.png" data-lazy- height="62" src="data:image/svg xml,” width=”716″>

Within the terminal shell, we have been located at the home directory of the Ubuntu 20.04 system. And the downloaded file is located in the Downloads directory. To extract the “tar” file, we must move into the “Downloads” folder first using the “cd” command of Ubuntu 20.04. It will directly take you within the “Downloads” directory as per the output in the image below. Now, list all the files and folders of the “Downloads” directory using the “ls” command. You can see that we currently have 2 “tar” files. One of these “tar” files is just downloaded from the web. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image9-3.png" data-lazy- height="57" src="data:image/svg xml,” width=”546″>

Before looking at extracting the single from the “tar” bundle, you need to know how to extract the whole “tar” file at once. For that, you need to make use of the “tar” command with the “-xvf” option and the name of a “tar” file while we are currently located at the “Downloads” folder. The option “x” is used for extraction, “-v” is used to display in ascending order, and “-f” is used to perform the extraction forcefully. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image8-5.png" data-lazy- height="345" src="data:image/svg xml,” width=”579″>

Now, we have to take a look at the Downloads folder again. So, we will be using the list command to do so. This list command shows us the uncompressed folder for the “tar” file of “cmake” along with the 2 original “tar” files. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image12-2.png" data-lazy- height="40" src="data:image/svg xml,” width=”651″>

Now, we have to take an inner look at the extracted folder. So, move into the extracted folder first using the “cd” command and the folder path. List the contents of the “cmake” folder using the “ls” command. The output shows all the extracted files for the “cmake” tar file. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image10-2.png" data-lazy- height="145" src="data:image/svg xml,” width=”650″>

Now, if you want a single file or folder from the “tar” file, you need to use the name of the “tar” file and the path to a single file in it. So, we have used the “tar” command with the “-xvf” option, the name of the “tar” file, and the path of a file to be extracted from it as below. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image11-2.png" data-lazy- height="56" src="data:image/svg xml,” width=”719″>

Now, we will move into the “cmake” extracted folder using the “cd” command and use the “ls” list instruction to display its contents. It displayed the single extracted file “bootstrap” within the “cmake” folder. Just run the command shown in the attached screenshot on the Linux terminal.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image13-2.png" data-lazy- height="55" src="data:image/svg xml,” width=”617″>

Conclusion:

This was all about extracting a single file from the “tar” within Ubuntu 20.04 Linux operating system. We have to go through the extraction of a whole “tar” file using the “tar” instruction and then use the command to extract a single file utilizing its path.

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/omar-150×150.png6254e95859e50.jpg" height="112" src="data:image/svg xml,” width=”112″>

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.