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. Given this structure, the site admin could extract your incoming archive directly to the server’s root directory.
Online Tools
- The extraction method is precisely the same for tar files that have compression, such as.tar.gz,.tar.bz2, and others.
- This article provides detailed guides to unzip .tar.gz files in Linux and Windows, as well as a few helpful tips and tricks.
- Use the following command to compress an entire directory or a single file on Linux.
- If you want to see the progress of the compression, you can use the -v option, which makes the tar command more verbose and prints the names of the files being added to the archive.
If you’re familiar with packages in Linux, you may have come across a TAR or a TAR.GZ file. While experienced users know what is a TAR file and how to extract it, Linux newbies might face some difficulties in figuring out what to do with it. It also integrates with the Windows Explorer context menu, which enables users to create and extract archives directly from the right-click menu. You can easily extract .tar.gz files using third-party tools like 7 zip and Winrar on the Windows system. You can notice in the above image that the archive files are extracted in the same working directory. But it does not compress the data, which results in a larger file size compared to compressed formats.
Only extract specific files or directories from .tar.gz in Linux
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.
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. 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 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.
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. Connect and share knowledge within a single location that is structured and easy to search. The c, v, z, and f flags used in the aforementioned command stand for Create, Verbose, gzip, and Filename.
Extract a Single Directory from a Tarball
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. 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.
In Linux, users have multiple ways to extract .tar.gz files – through the terminal and graphical file archivers. 7-Zip is a free and open-source tool with high compression ratios & supports a wide range of archive formats. It offers AES-256 encryption to protect sensitive data within archives. Users can utilize the 7-zip command-line interface for automated & scripted extraction tasks. To unzip the .tar.gz files, you’ll need to use specific commands and tools depending on your operating system. Let’s explore the extraction process for both Linux & Windows platforms.
For sending and storing, both .zip and .tar.gz files allows you to send relatively large packages as a single file. However, there are some pretty major differences when it comes to accessing data within the files and the compression efficiency. 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. The following command will extract the contents of archive.tar.gz to the current directory. If you want to create your own tar.gz file, you can use the tar command with the -c option, which tells tar to create a new archive.
This error usually occurs when a .tar has been saved as a .gz despite having never been compressed using the gzip utility. It may sound like a silly mistake, but it’s surprisingly common in situations where users directly rename files and their extensions (such as .tar and .gz) in the process. Unlike Windows’ convenient graphical user interface (GUI) for unzipping .zip files, you need to use the tar utility through the command line.
Untar Tar.gz – Linux Tar Command – HowTo: Extract Tar File
The command includes a large number of additional options, so we can’t possibly list them all here. Run the info tar command at the shell to view the tar command’s detailed information page. 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.
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 what is a fixed budget unzipping a .zip, it’s still pretty straightforward.
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. The tar format only creates a container for files, but the files can be compressed with separate utilities. Common compressions applied to a .tar file are Gzip, bzip2, and xz.
The command will extract the files and directories in the current working directory, preserving the original permissions and ownership. 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.
The next section shows how .tar comes with a few extra features that make it the better compression format for certain files and applications. You’ll probably have to install the “other” tar (whatever that may be on your system) manually. 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.” 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.