How to unzip a tar gz file
Like the tar utility, gzip also allows you to zip and unzip multiple files or entire directories at a time. 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. This command extracts (-x) the file (-f) specified (in this case, filename.tar.gz) to the current directory. Note that this command also works with other common compression formats such as .tar.bz2. Though gzip is the most common compression utility, it’s not the only one.
Oreon: A Fresh AlmaLinux-Based Distro Designed for Desktop Users
- As we cover more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command.
- DEB is the native and most common package format Ubuntu and other Debian-based Linux distributions use.
- The command extracts files to a new directory called example1, which is located in the current directory.
- For sending and storing, both .zip and .tar.gz files allows you to send relatively large packages as a single 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. 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.
As a result, one isn’t necessarily better than the other — it’s all a matter of application. The Dolphin file manager offers a feature to autodetect whether the files extracted from an archive are contained in a directory or if a new directory needs to be created for them. I use this option so that when I extract files from a tarbomb, they remain tidy and contained.
This article provides detailed guides to unzip .tar.gz files in Linux and Windows, as well as a few helpful tips and tricks. This is because most versions of tar allow both gnu and bsd style options (simplistically, gnu requires a hyphen, bsd doesn’t). Perhaps you might also be interested in learning how to unzip files in Linux.
The extraction method is precisely the same for tar files that have compression, such as.tar.gz,.tar.bz2, and others. Knowing how to unzip a .tar.gz file allows users to extract and access the archives’ contents efficiently. 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. Compressing and extracting these files, however, isn’t always intuitive.
Extract a tarball to another directory
Click on the Extract Here option to unzip the content of the file. The system will extract all the files to your current directory by default. For TAR.GZ files, you will have to unzip the compressed archive to TAR, and then further extract the TAR file using 7-Zip. The -so and -si flags denote Standard Output and Standard Input. The first part of the command writes the archive.tar file to the standard output. The second command reads the archive.tar file from the standard input and compresses it accordingly.
Extract a Tar File
If the file is a bzip2-compressed file, replace the “z” in the above commands with a “j”. Once you have an archive, you can extract it with the tar command. The following command will extract the contents of archive.tar.gz to the current directory. If you want to unzip the files to a different folder, click on the Extract To option. Choose the appropriate location and click Select to extract the file to that location.
This error occurs when trying to extract specific files or directories from a .tar.gz file using tar. If you want to keep the original file after compression, there are two options. The first is what is monero 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.
Creating a tarball
The tar command is extremely powerful, and you can do things like list or search for files in a tar archive, or extract a single file. Unlike Windows’ convenient graphical user interface (GUI) for unzipping .zip files, you need to use the tar utility through the command line. However, there are also many third-party tools you can install for a more user-friendly experience. When you want to share multiple files with someone else, compressing those files into a single TAR archive is the most efficient solution. Apart from occupying less space on your system storage, compressed archives utilize less server bandwidth when downloaded by multiple users. And now you can use the 7-Zip File Manager to open, view, or extract files from tar.gz and other archives.
Use the –exclude flag to specify the names of the files that you don’t want to extract. 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.
Once you choose the directory, click the Select button in the top right corner.
Then we’ll jump into the step-by-step process of unzipping on both Linux and Windows platforms. Once you’ve selected the right file, you’ll see “7-Zip File Manager” show up in the select app dialog. 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. Once you’ve downloaded and installed 7-Zip, double-click on the tar.gz file that you’re trying to open, and then select “Choose an app on your PC” from the popup dialog that shows up. Similar to the previous error, this error occurs when an archive was saved as a .tar despite not being a .tar archive.