How to Extract tar gz File in Linux by Using the Command Line


how to extract tar gz

Common compressions applied to a .tar file are Gzip, bzip2, and xz. That’s why you rarely see just a .tar file and more commonly encounter .tar.gz or .tgz files. By default, tar extracts the archive contents in the current working directory. If you want to extract the files to a different directory, you can use the -C option, which tells tar to change the directory before extracting the files.

Is .tar.gz more efficient than .zip?

With the command prompt open, use the appropriate commands to change the current working directory (cd) to the location of the .tar.gz file you want to unzip. Alternatively, you can also specify a source and destination file path when using the tar utility. The tar command also provides support for extracting only specific files or directories from a .tar.gz file.

Click on the Extract Here option to unzip the content of the file. The system will extract all the files to your current directory by default. For TAR.GZ files, you will have to unzip the compressed archive to TAR, and then further extract the TAR file using 7-Zip. If you want to extract the files to a specific directory, you can use the -C option followed by the directory path. Whether you prefer command-line tools or graphical file archivers, the extraction process is pretty simple.

Using the tar Utility

  1. You need to specify the path to the directory where you want to extract the files after the -C option.
  2. In the shell, you can add a file or directory to a tar archive as long as it is not compressed.
  3. Once you’re comfortable with the basics, it’s useful to explore other features.
  4. There are several ways to extract or unzip a tar.gz file in Linux, depending on the tool you have available or prefer to use.

Short for “Tape ARchive,” the name “TAR” is a throwback to when files were stored on magnetic tape drives. In this guide, you will learn how to extract or unzip .tar.gz files in Linux. In the shell, you can add a file or directory to a tar archive as long as it is not compressed. If your archive has been compressed, you must uncompress it, but you do not need to unarchive it. These kinds of archives are sometimes called a tarbomb, although not always with a negative connotation.

how to extract tar gz

How to Extract tar.gz File in Linux by Using the Command Line

You can also add the verbose output option (-v) to provide detailed listings, including dates, securities/permissions, and more. Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows. Any remotely modern version of tar should auto-detect that the archive is gzipped, and add “z” for you.

This is good and pretty comprehensive, Seth.One thing to point out is that, since .jpg and .png files are already compressed, you won’t get much compression with gzip. You’ll probably have to install the “other” tar (whatever that may be on your system) manually. You can specify one or more files or directories to include in the archive. If you specify a directory, tar will recursively archive all the files and subdirectories in that directory. Sometimes you need to view the 25 high-dividend stocks and how to invest in them content of a tar file as it collects many files and ensures if a specific file is present. File compression is a great way to save storage on a computer.

A user-friendly way to extract files from a .tar.gz archive is via a Graphical User Interface (GUI). A GUI is more suitable for beginners than a command-line tool. DEB is the native and most common package format Ubuntu and other Debian-based Linux distributions use.

how to extract tar gz

This error occurs when trying to extract specific files or directories from a .tar.gz file using tar. If the command line isn’t your thing, there are plenty of user-friendly tools available to unzip tar.gz files. But with .zip being the easier of the two to use, why use .tar in the first place? The next section shows how .tar comes with a few extra features that make it the better compression format for certain files and applications.

Most of the time, you will get your hands on a compressed package that needs extracting. On Linux, there are multiple ways to unzip compressed archives. To extract the tar.gz file, you’ll use the tar command followed by -xzf and the name of the file. The -xzf stands for extract (-x), gzip files (-z), and file (-f). In Linux, users have multiple ways to extract .tar.gz files – through the terminal and graphical file archivers. To unzip the .tar.gz files, you’ll need to use specific commands and tools depending on your operating system.

Extract to a Specific Directory File

If you want a specific file, you can drill down into the folder, or you can simply click the “Extract” button and choose a location to put all the files. This error usually occurs when a .tar has been saved as a .gz despite having never been compressed using the gzip utility. It may sound like a silly mistake, but it’s surprisingly common in situations where users directly rename files and their extensions (such as .tar and .gz) in the process.

The tar program takes one or more files and “wraps” them into a self-contained file. Locate the compressed archive file and right-click on it to bring up the menu. Similarly, you can unzip specific directories from the archive as well. Creating archives is an important step when you’re backing up your Linux file system. This ensures that your backup remains unaffected and the files don’t corrupt if anything breaks on your system. Don’t be afraid to explore more about the tar command and other terminal commands.

This format is common in the Unix/Linux world and is widely used to create compressed archives. It’s easy to get confused when navigating between .tar, .tar.gz, and .gz – not to mention zipping and unzipping them. Here are a few frequently asked questions we commonly hear from users working with .tar.gz files. Some third-party tools also offer extended flexibility for converting between file types‌, saving more time if you want to change between compression formats.


Leave a Reply

Your email address will not be published.