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

how to extract a tar.gz

Decompressing TAR and TAR.GZ files is only a matter of few clicks using the GUI. Similarly, you can unzip specific directories from the archive as well. It’s the same as the archive creation command we used above, except the -x switch replaces the -c switch. This specifies you want to extract an archive instead of create one. To extract a single file, provide the path and the name of the file. As the files are extracted, they are listed in the terminal window.

current community

how to extract a tar.gz

Ubuntu versions are usually named using an alliterative adjective and an animal name, both starting with the same letter. You can combine both steps into a single command as well. The c, v, z, and f flags used in the aforementioned command stand for Create, Verbose, gzip, and Filename. We can see that the Ukulele Songs directory contains directories called Random upgrading wi-fi security from wep to wpa2 security Songs, Ramones and Possibles. Once you’ve done this successfully, you’ll notice that the icon for tar.gz files will change to a 7-Zip icon.

How to Unzip .tar.gz in Linux using tar

It is usually convenient to pipe the output through the less command. List the files in the directory with ls and you’ll see that a directory has been created called Ukulele Songs. It was contained in the tar file, and was extracted along with the files. Again, the above command extracts to the current working directory by default. You can use the -C option to extract to a different directory (in this case, how to buy bitcoin cash with debit card in usa how to buy dogecoin kraken /home/user/files).

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. Use the –exclude flag to specify the names of the files that you don’t want to extract. Creating archives is an important step when you’re backing up your Linux file system.

What command do I need to unzip/extract a .tar.gz file?

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. Note that this command will throw an error unless you specify the exact filename listed in the .tar file. As we cover more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command. Compressing and extracting these files, however, isn’t always intuitive.

  1. Short for “Tape ARchive,” the name “TAR” is a throwback to when files were stored on magnetic tape drives.
  2. Notice that we don’t need to use the -z option to list the files.
  3. If you want to unzip the files to a different folder, click on the Extract To option.
  4. Most Linux distributions ship with a preinstalled archive manager.
  5. Once you have an archive, you can extract it with the tar command.

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. 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. Thankfully, you don’t need to be a 1960s computer technician to use and extract .tar files – nor do modern .tar files even have anything to do with old computers.

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. From videos to entire software packages, many files are compressed and stored using the .tar.gz format.

Manjaro 24.1 “Xahea” Released, Here’s What’s New

As a result, one isn’t necessarily better than the other — it’s all a matter of application. Where most operating systems make it easy to extract and create .zip files, the same can’t really be said for .tar files — at least not in ways that are easy to notice. The collective -xvzf flag stands for Extract, Verbose, gzip, and Filename respectively. Anything that follows the -f option is treated as the input file. Note that if you are working with TAR files, you can remove the -z flag from the commands. The tar command can extract the resulting archives, too.

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. 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.

If you don’t want the directory structure in the tar file to be recreated on your hard drive, use the –strip-components option. 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 digital artist opportunities contents of a tar file before you extract it by using the -t (list) option.