Posted on Leave a comment

How to Unzip a Tar gz File in Linux

how to unzip a tar.gz file

The GNU tar command included with Linux distributions has integrated compression. It can create a .tar archive and then compress it with gzip or bzip2 compression in a single command. That’s why the resulting file is a .tar.gz file or .tar.bz2 file. You’ll encounter them frequently while using a Linux distribution like predictive analytics Ubuntu or even while using the terminal on macOS. Here’s how to extract — or untar — the contents of a tar file, also known as a tarball. Like the tar utility, gzip also allows you to zip and unzip multiple files or entire directories at a time.

How to Compress and Extract Files Using the tar Command on Linux

Now the file “four” is extracted to a new directory called “bar.” If “bar” already exists, then “four” is placed inside the existing directory. If you’ve received a tarball from a friend or a software project, you can extract it in either your GUI desktop or in a shell. In a GUI, right-click the archive you want to extract and select “Extract.” The -p (parents) option causes mkdir to create any parent directories that are required, ensuring the target directory is created. As the files are extracted, they are listed in the terminal window. Once you’ve selected the right file, you’ll see “7-Zip File Manager” show up in the select app dialog.

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

The biggest advantage of tar.gz files is that they are more compact and easier to handle than other compressed archive formats. If the file is a bzip2-compressed file, replace the “z” in the above commands with a “j”. Use the following command to compress an entire directory or a bitcoin future prediction reddit single file on Linux.

  1. 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.
  2. The number represents how many levels of directories to ignore.
  3. I use this option so that when I extract files from a tarbomb, they remain tidy and contained.
  4. As you might imagine, using a different compression utility on a .tar file will result in a different double extension.
  5. Some third-party tools also offer extended flexibility for converting between file types‌, saving more time if you want to change between compression formats.

Gzip is faster, but it generally compresses a bit less, so you get a somewhat larger file. Bzip2 is slower, but it compresses a bit more, so you get a somewhat smaller file. Gzip is also more common, with some stripped-down Linux systems including gzip support by default, but not bzip2 support. In general, though, gzip and bzip2 are practically the same thing, and both will work similarly. In some cases, you may wish to compress an entire directory, but not include certain files and directories. You can do so by appending an –exclude switch for each directory or file you want to exclude.

GNU tar and BSD tar

how to unzip a tar.gz file

If you want 7-Zip to always handle tar.gz files in the future, you’re going to want to select the “Always” button at the bottom of the dialog. In the option box that shows up, choose how and where you want to unzip your tar.gz file. If you have an existing tarball and want to add a new file into it, you don’t have to unarchive everything just to add a new file. To extract a single file, provide the path and the name gambling with digital and virtual currencies of the file.

Where commands have little (if any) room for typos or 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. The tar command also provides support for extracting only specific files or directories from a .tar.gz file. Simply add a space-separated list of the files you want to extract.

The .tar portion of the file extension stands for tape archive, and is the reason that both of these file types are called tar files. Tar files date all the way back to 1979 when the tar command was created to allow system administrators to archive files onto tape. Forty years later we are still using the tar command to extract tar files on to our hard drives. Where .zip files consist of many individually compressed files, .tar files are compressed as a single package, leaving its files uncompressed. In other words, .zip files are a collection of compressed files, while .tar files are a compressed collection of files. People new to the tar format usually equate it to a .zip file, but a tar archive is notably not compressed.

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. 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 can create your own compressed .tar files using compression utilities such as gzip. Gzip is one of the most popular and available options, especially since it comes built in to most Linux distributions and macOS.

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องข้อมูลจำเป็นถูกทำเครื่องหมาย *