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. On the other hand, Windows users can rely on third-party file archiver tools like 7-zip or WinRAR to effortlessly extract files. In Linux, users have multiple ways to extract .tar.gz files – through the terminal and graphical file archivers. This format is common in the Unix/Linux world and is widely used to create compressed archives.
You can also choose the destination directory where you want to extract the files. To extract a tar.gz file using the tar command, you need to use the -x option, which tells tar to extract the files from the archive. You also need to use the -z option to indicate that the archive is compressed with gzip, and the -f option to specify the file name. Learn how to extract or unzip tar.gz files in Linux using the tar command and other tools. Find out how to list, extract, and create tar.gz archives.
You can also use –wildcards to extract all files with a certain extension or name. Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows. The output shows a newly created archive example1.tar.gz. Snaps were developed by Canonical, the company behind Ubuntu, to package and distribute software focusing on security, sandboxing, and ease of installation and updates.
How to Zip and Unzip or Extract TAR and TAR.GZ Files
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. While extracting a .tar.gz file isn’t quite as easy as unzipping a .zip, it’s still pretty straightforward. You can also extract only specific files or directories from a tar.gz archive, by providing their names after the archive name. You need to use the exact names and paths as listed by the tar -t command. The command will extract the files and directories in the current working directory, preserving the original permissions and ownership.
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.
Canonical released its first official version of the OS, Ubuntu 4.10, codenamed ‘Warty Warthog’ in October 2004. Canonical released its first official version of the OS, Ubuntu 4.10, codenamed ‘Warty Warthog’ in October 2004. Ubuntu is a Southern African philosophy and term originating from South Africa and Zimbabwe.
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. 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.
Saving Storage and Bandwidth on Linux
Gzip is one of the most popular and available options, especially since it comes built in to most Linux distributions and macOS. As we see later, different compression utilities may require different methods for extracting and unzipping files. 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. 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. Just like the more familiar .zip files, .tar files compress large files into a single package, making it easier to store and send them through email, servers, and so on.
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. You may also be interested in learning about the best WinZip alternatives to compress files. Then we’ll jump into the step-by-step process of unzipping on both Linux and Windows platforms. We can see that the Ukulele Songs directory contains directories called Random Songs, Ramones and Possibles. To access the Windows command line, search for “command prompt” or “cmd” in the search bar.
You can specify operating activities definition one or more files or directories to include in the archive. If you specify a directory, tar will recursively archive all the files and subdirectories in that directory. Ubuntu LTS (Long-Term Support) versions, known for their stability and extended support periods, are typically released every two years in April. These are popular for organizations and users who require a reliable and well-supported Ubuntu operating system. Sometimes you need to view the content of a tar file as it collects many files and ensures if a specific file is present. Many of the downloadable Linux/Unix files found on the internet are compressed using a tar.gz format.
Right-click the first result and select the “Run as administrator” option. 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. If you find this article helpful or have additional ideas, please use the comment box below.
- This command extracts (-x) the file (-f) specified (in this case, filename.tar.gz) to the current directory.
- On Linux, there are multiple ways to unzip compressed archives.
- The .gz or .bz2 extension suffix indicates that the archive has been compressed, using either the gzip or bzip2 compression algorithm.
Using the tar Utility
You just need to use the appropriate tar command line options. Since .tar.gz compresses multiple files all at once, it can take advantage of similarities between individual files to save on space. Generally speaking, a collection of files archived and compressed as a .tar.gz are more space-efficient (i.e., smaller) than the same collection compressed as a .zip. Where commands have little (if any) room for typos or omissions, many common errors are the result of small mistakes, misspellings, or incorrect formats.
How to Extract a tar.gz File to a Different Directory
A tar.gz file is a compressed archive format commonly used in Linux systems to combine multiple files and directories into a single file while reducing their size. It combines the tar utility for archiving and the gzip utility for compression. Knowing how to extract or unzip a tar.gz file allows users to access and manipulate the archives’ contents efficiently. In this article, you learned how to extract or unzip tar.gz files in Linux using the tar command and other tools.
A GZ file is nothing but a file compressed using the gzip algorithm. You can use the official GNU gzip utility to extract the content of the compressed archive file. If the file you’re looking at is a TAR.GZ, using either tar or 7-Zip to extract the file will be a much simpler choice. Most of the time, you will get your hands on a compressed package that needs extracting.
If you’re not comfortable with the terminal or command line, third-party tools such as 7-Zip offer a more user-friendly alternative. 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. You can easily unzip the resulting .tar.gz file with the decompress (-d) option. This is because most versions of tar allow both gnu and bsd style options (simplistically, gnu requires a hyphen, bsd doesn’t). 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.