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

how to untar tar gz file

Here are a few frequently asked questions we commonly hear from users working with .tar.gz files. This error occurs when trying to extract specific files or directories from a .tar.gz file using tar. Where commands have little (if any) room for typos or where to buy audius token omissions, many common errors are the result of small mistakes, misspellings, or incorrect formats. Thankfully, unless you’re somehow missing your tar or gzip utility, most common errors are very easy to fix.

how to untar tar gz file

List the Contents of a tar, tar.gz, tar.bz2 Files

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. Similar to the previous error, this error occurs when an archive was saved as a .tar despite not being a .tar archive.

You can easily unzip the resulting .tar.gz file with the decompress (-d) option. 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.

Only extract specific files or directories from .tar.gz in Linux

As we cover more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command. 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. 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. It’s easy to get confused when navigating between advfn 2018 international financial awards .tar, .tar.gz, and .gz – not to mention zipping and unzipping them.

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. Choose the directory to extract your files to. The output shows a newly created archive example1.tar.gz. File compression and extraction is part of system administration. You must perform these operations using the applications that come with the operating system itself.

Extract a Single File from a Tarball

  1. Though gzip is the most common compression utility, it’s not the only one.
  2. We have 2 ways to open tar.gz files (tar, gunzip).
  3. To use gunzip, the gzip package is installed.
  4. As we cover more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command.

If you plan to distribute and store .tar.gz files on your website, Kinsta’s managed hosting services can help make the most of your space. Let’s do the steps we mentioned above with gunzip. Here I have a wrapper archive which internally contains 2 nested gzip archives. The -C option is used to specify a different directory other than the current working directory.

To use gunzip, the gzip package is installed. In fact, tar and gzip packages come pre-installed on many operating systems. Some operating systems give packages like “sudo”, “gnome” as dependent packages. Therefore, it may not be possible to remove them. So how to install tar and gzip(gunzip) packages? You can find the answer to this question below.

The most often used algorithm for compressing tar files is Gzip. By convention, the name of a tar archive compressed with gzip becomes .tar.gz or .tgz. 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. As a result, one isn’t necessarily better than the other — it’s all a matter of application.

Though we mostly focus on .tar.gz files, check out the end of the article for some quick tips on extracting .tar files in other formats. Ubuntu Core is a minimalistic how to buy bitcoin in 7 steps 2021 and immutable version explicitly designed for the Internet of Things (IoT) and embedded systems. While every tar.gz file is a .tar archive, not every .gz is a .tar file. The .gz extension represents the gzip compression format, which can be applied to almost any file format to compress data and save space. 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.

However, tar was unable to find FILE within .tar.gz, meaning that the user either misspelled the name or that the file simply doesn’t exist in filename.tar.gz. Another common cause of errors is case sensitivity, where Linux treats “FILE” and “file” as two separate entities. If you want to keep the original file after compression, there are two options. The first is the -k option, and the other uses the -c option to output the compressed file to a different file, preserving the original.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *