Skip to main content

How to Extract or Unzip tar.gz Files in Linux

By July 9, 2021August 29th, 2024Cryptocurrency News

how to untar the tar.gz file

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. You will learn how to list the contents of a tar archive without unpacking it and how to extract only a single file or a single directory. Most of the time, you will get your hands on a compressed package that needs extracting.

You can notice in the above image that the archive files are extracted in the same working litecoin price prediction 2020 directory. 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. If you want to keep the original file after compression, there are two options.

how to untar the tar.gz file

Note that the path is wrapped in quotation marks because there are spaces in the path. Notice that we bitcoin complete guide to mastering bitcoin mining trading and investing pdf don’t need to use the -z option to list the files. We only need to add the -z option when we’re extracting files from a .tar.gz file. Likewise, we don’t need the -j option to list the files in a tar.bz2 file. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line. The -so and -si flags denote Standard Output and Standard Input.

This compression is lossless – that means no data is lost during the compression process, and the original files can be fully restored upon extraction. You can open most .tar.gz files using the tar command built in to Linux, macOS, and Windows 10. If you’re not comfortable with the terminal or command line, third-party tools such as 7-Zip offer a more user-friendly alternative. In this example, the user tried to extract the file titled “FILE” from filename.tar.gz.

How to Unzip .tar.gz in Linux using tar

The –strip-components option requires a numerical parameter. The number represents how many levels of directories to ignore. Files from the ignored directories are still extracted, but the directory structure is not replicated on your hard drive. So far we’ve just taken a leap of faith and extracted the files sight unseen. You can review the contents of a tar file before you extract it by using the -t (list) option. It is usually convenient to pipe the output through the less command.

How to Extract a tar.gz File to a Different Directory

The aforementioned command will extract the archive.tar.gz file to the /Downloads folder. The name “Tar” stands for “Tape Archiver” because it was used to place data on storage tapes when tar was invented. The tar program takes one or more files and “wraps” them into a self-contained file.

Unzip .tar.gz in Linux

It is still used today for consolidating and compressing data. Archives created with tar are typically saved with a .tar extension and can also be compressed to save space, resulting in files like .tar.gz or .tar.bz2. Though both .zip and .tar.gz archive and compress files, they do so in different ways. In other words, .zip is a collection of compressed files, while .tar.gz is a compressed collection of files. WinRAR is a popular file compression & archive utility software. Where .zip files consist of many individually compressed files, .tar files are compressed as a single package, leaving its files uncompressed.

Thankfully, unless you’re somehow missing your tar or gzip utility, most common errors are very easy to fix. Unlike Windows’ convenient graphical user interface (GUI) for unzipping .zip files, you need to use the tar utility through the command line. However, there what are the best ways to store bitcoins safely are also many third-party tools you can install for a more user-friendly experience. Though gzip is the most common compression utility, it’s not the only one. As you might imagine, using a different compression utility on a .tar file will result in a different double extension. Some common examples include .tar.bz2 (bzip2), .tar.br (Brotli), and .tar.zst (zstd), among many others.

List contents of .tar.gz file in Linux

  1. So far we’ve just taken a leap of faith and extracted the files sight unseen.
  2. Snaps were developed by Canonical, the company behind Ubuntu, to package and distribute software focusing on security, sandboxing, and ease of installation and updates.
  3. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line.
  4. Files that have a .tar.gz or a .tar.bz2 extension are compressed archive files.
  5. On Linux, there are multiple ways to unzip compressed archives.
  6. A GUI is more suitable for beginners than a command-line tool.

To do this we’ll use almost exactly the same command as before but with one important difference. The .bz2 extension suffix tells us it has been compressed using the bzip2 command. Instead of using the-z (gzip) option, we will use the -j (bzip2) option to unzip the bz2 file. A GZ file is nothing but a file compressed using the gzip algorithm. You can use the official GNU gzip utility to extract the content of the compressed archive file.

If you’re familiar with packages in Linux, you may have come across a TAR or a TAR.GZ file. While experienced users know what is a TAR file and how to extract it, Linux newbies might face some difficulties in figuring out what to do with it. Ubuntu LTS (Long-Term Support) versions, known for their stability and extended support periods, are typically released every two years in April.

These are popular for organizations and users who require a reliable and well-supported Ubuntu operating system. Sometimes you need to view the content of a tar file as it collects many files and ensures if a specific file is present. Many of the downloadable Linux/Unix files found on the internet are compressed using a tar.gz format. Therefore, knowing how to open or untar tar.gz files is very useful.

If the file you’re looking at is a TAR.GZ, using either tar or 7-Zip to extract the file will be a much simpler choice. The following tar examples cover how to untar both popular formats and extract the contents of the compressed archive to a different directory. The most often used algorithm for compressing tar files is Gzip.

A few simple commands are all it takes to untar, unzip or extract tar gz files from within running Linux or Unix operating environments. Hopefully this has helped you decompress, unpack and extract those compressed tar and tar gz files you downloaded from the internet. If you are looking for additional helpful solutions, you might want to check out this right mouse click open files as root article. In Linux, the term “untar command” isn’t a standalone command. Instead, it commonly refers to the process of extracting, unzipping, or uncompressing tar and tar.gz files from a tar archive.

A file with just a .tar extension is uncompressed, but those will be very rare. People new to the .tar format usually equate it to a .zip archive, but a tar archive is not compressed. Tar collected all the files into one package, but the files can be compressed with separate utilities.

danblomberg

Author danblomberg

More posts by danblomberg