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

how to untar a tar.gz file

A “.tar” file is a collection of files compressed into a single file or archive. Short for “Tape ARchive,” the name “TAR” is a throwback to when files were stored on magnetic tape drives. You don’t need to untar tar.gz files every time you want to add a new file to the archive. If you’re using a Linux OS, you can open the tar archive just as you open any other directory.

You can just as easily unzip the resulting .tar.gz file with the decompress (-d) option. You can also use –wildcards to extract all files with a certain extension or name. For example, it goes without saying, that it is inadvisable to untar the whole large archive if you need for example to extract only a dingle file or a directory from it. The command extracts files to a new directory called example1, which is located in the current directory.

Related Articles

Ubuntu is a Southern African philosophy and term originating from South Africa and Zimbabwe. The -C option is used to specify a different directory other than the current working directory. 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.

However, while tools like 7-Zip are free, many more “robust” solutions are only available for a price after a trial period. As a result, we recommend sticking to free (but trustworthy) tools or simply using the command line. To access the Windows command line, search for “command prompt” or “cmd” in the search bar. Right-click the first result and select the “Run as administrator” option. You will find answers to these questions in this article. Canonical released its first official version of the OS, Ubuntu 4.10, codenamed ‘Warty Warthog’ in October 2004.

For more information and to schedule a live demo, contact a hosting expert from Kinsta today. While there are many tools to choose from, the most popular include 7-Zip and WinZip. While slightly different, they are quite lightweight and offer a much simpler alternative to using the command line. Once you choose the directory, click the Select button in the top right corner.

how to untar a tar.gz file

Thankfully, unless you’re somehow missing your tar or gzip utility, most common errors are very easy to fix. It’s often useful to list the contents of a .tar.gz file without having to unzip the entire archive. The -list (-t) option will output a list of filenames. Though gzip is the most common compression utility, it’s not the only one.

What does it mean to untar tar.gz files?

Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows. And of course this is possible with the Linux tar command, but firstly you need to check what is there inside the tarball without unpacking it. The -p (parents) option lets mkdir create and parent directories you need. This ensures that the target directory is created.

Extract all content with tar command, extract a specific file and list the files without extracting them. 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. Where commands have little (if any) room for typos or omissions, many common errors are the result of small mistakes, misspellings, or incorrect formats.

  1. They were officially introduced in Ubuntu 16.04 LTS, released in April 2016.
  2. In other words, .zip is a collection of compressed files, while .tar.gz is a compressed collection of files.
  3. 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.
  4. As a result, one isn’t necessarily better than the other — it’s all a matter of application.
  5. As you can see, the contents of the archive are successfully extracted to the current folder.

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. But with .zip being the easier of the two to use, why use .tar in the first place? As we’ll see in the next section, .tar comes with a few extra features that make it the better compression format for certain files and applications. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line.

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

So we can list the content of the archive without actually extracting everything by using -tz argument where -t is for –list i.e. list the contents of the archive. In fact, tar and gzip packages come pre-installed on many operating systems. Some operating systems give packages like “sudo”, “gnome” as dependent packages.

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

Simply add a space-separated list of the files you want to extract. 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. From videos to entire software packages, many files are compressed and stored using the .tar.gz format. While extracting a .tar.gz file isn’t quite as easy as unzipping a .zip, it’s still pretty straightforward. This error usually occurs when a .tar has been saved as a .gz despite having never been compressed using the gzip utility. 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.

Note that this command also works with other common compression formats such as .tar.bz2. Most Linux distributions and macOS include built-in tools for zipping and unzipping .tar and .tar.gz files. While the tar utility is enough for most purposes, you’ll need the gzip utility to create .tar.gz files. But to be able to know the filename, we must check the content of the archive.

Perhaps you might also be interested in learning how to unzip files in Linux. This error occurs if you try to decompress a file without specifying a decompression utility, specifically -z for gzip. In this example, the user tried to extract the file titled “FILE” from filename.tar.gz. 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.

Here are a few frequently asked questions we commonly hear from users working with .tar.gz files. 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.

Using the Command Line (cmd)

Note the lack of hyphen for the command flags. This is because most versions of tar allow both gnu and bsd style options (simplistically, gnu requires a hyphen, bsd doesn’t). 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.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Conoce cuánto puedes ahorrar de luz en tu casa o en tu negocio

Suscríbete a
nuestro newsletter

Gracias por contactarnos, tu mensaje ha sido enviado con éxito

En breve un asesor de energía se pondrá en contacto contigo.