How to Extract Files From a .tar.gz or .tar.bz2 File on Linux

Bash shell on Unity desktop conceptFatmawati Achmad Zaenuri/Shutterstock.com

Tar files are compressed archives. You’ll encounter them frequently while using a Linux distribution like Ubuntu or even while using the terminal on macOS. Here’s how to extract—or untar—the contents of a tar file, also known as a tarball.

What Does .tar.gz and .tar.bz2 Mean?

Files that have a .tar.gz or a .tar.bz2 extension are compressed archive files. A file with just a .tar extension is uncompressed, but those will be very rare.

The .tar portion of the file extension stands for tape archive, and is the reason that both of these file types are called tar files. Tar files date all the way back to 1979 when the tar command was created to allow system administrators to archive files onto tape. Forty years later we are still using the tar command to extract tar files on to our hard drives. Someone somewhere is probably still using tar with tape.

The .gz or .bz2 extension suffix indicates that the archive has been compressed, using either the gzip or bzip2 compression algorithm. The tar command will work happily with both types of file, so it doesn’t matter which compression method was used—and it should be available everywhere you have a Bash shell. You just need to use the appropriate tar command line options.

Extracting Files from Tar Files

Let’s say you’ve downloaded two files of sheet music. One file is called ukulele_songs.tar.gz , the other is called guitar_songs.tar.bz2. These files are in the Downloads directory.

Two tar files in the downloads directory

Let’s extract the ukulele songs:

tar -xvzf ukulele_songs.tar.gz
 

As the files are extracted, they are listed in the terminal window.

Extraction of all files from tar file

Read the remaining 33 paragraphs

Source: https://www.howtogeek.com/409742/how-to-extract-files-from-a-.tar.gz-or-.tar.bz2-file-on-linux/
Proactive Computing found this story and shared it with you.
The Article Was Written/Published By: Dave McKay

Author: Droolin' Dog News Team