The aforementioned command will extract the archive.tar.gz file to the /Downloads folder. The name “Tar” stands for “Tape Archiver” because it was used to place data on storage tapes when tar was invented. The tar program takes one or more files and “wraps” them into a self-contained file.
How to Extract tar.gz File in Linux by Using the Command Line
You can use the -C option to extract to a different directory (in this case, /home/user/files). Of course, that’s not to say .tar files are some kind of “lesser” format than .zip. Rather, they both accomplish the same task (file compression) in the same way. If you don’t want the directory structure in the tar file to be recreated on your hard drive, use the –strip-components option.
Extract a Single File from a Tarball
This compression is lossless – that means no data is lost during the compression process, and the original files can be fully restored upon extraction. You can open most .tar.gz files using the tar command built in to Linux, macOS, and Windows 10. If you’re not comfortable how to create a btc wallet and way to make profit from it 2021 with the terminal or command line, third-party tools such as 7-Zip offer a more user-friendly alternative. In this example, the user tried to extract the file titled “FILE” from filename.tar.gz.
Thankfully, unless you’re somehow missing your tar or gzip utility, most common errors are very easy to fix. 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. Though gzip is the most common compression utility, it’s not the only one. As you might imagine, using a different compression utility on a .tar file will result in a different double extension. Some common examples include .tar.bz2 (bzip2), .tar.br (Brotli), and .tar.zst (zstd), among many others.
A file with just a .tar extension is uncompressed, but those will be very rare. People new to the .tar format usually equate it to a .zip archive, but a tar archive is not compressed. Tar collected all the files into one package, how to buy bitcoin through paypal but the files can be compressed with separate utilities.
Troubleshooting Common Errors
Similar to the previous error, this error occurs when an archive was saved as a .tar despite not being a .tar archive. 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. Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows. To extract a single file, provide the path and the name of the file.
- Though gzip is the most common compression utility, it’s not the only one.
- However, there are some pretty major differences when it comes to accessing data within the files and the compression efficiency.
- Looking in our Documents/Songs directory we’ll see the Guitar Songs directory has been created.
- The .bz2 extension suffix tells us it has been compressed using the bzip2 command.
The –strip-components option requires a numerical parameter. The number represents how many levels of directories to ignore. Files from the ignored directories are still extracted, but the directory structure is not replicated on your hard drive. So far we’ve just taken a leap of faith and extracted the files sight unseen. You can review the contents of a tar file before you extract it by using the -t (list) option. It is usually convenient to pipe the output through the less command.
By convention, the name of a tar archive compressed with gzip becomes .tar.gz or .tgz. 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.
List the files in the directory with ls and you’ll see that a directory has been created called Ukulele Songs. It was contained in the tar file, and was how to buy and sell bitcoins extracted along with the files. The collective -xvzf flag stands for Extract, Verbose, gzip, and Filename respectively. 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.
You may also be interested in learning about the best WinZip alternatives to compress files. 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. Connect and share knowledge within a single location that is structured and easy to search. We can see that the Ukulele Songs directory contains directories called Random Songs, Ramones and Possibles.
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. The following tar examples cover how to untar both popular formats and extract the contents of the compressed archive to a different directory. The most often used algorithm for compressing tar files is Gzip.
But with .zip being the easier of the two to use, why use .tar in the first place? The next section shows how .tar comes with a few extra features that make it the better compression format for certain files and applications. Thankfully, you don’t need to be a 1960s computer technician to use and extract .tar files – nor do modern .tar files even have anything to do with old computers. 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.
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. Files that have a .tar.gz or a .tar.bz2 extension are compressed archive files.
Note that the path is wrapped in quotation marks because there are spaces in the path. Notice that we don’t need to use the -z option to list the files. We only need to add the -z option when we’re extracting files from a .tar.gz file. Likewise, we don’t need the -j option to list the files in a tar.bz2 file. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line. The -so and -si flags denote Standard Output and Standard Input.
These files can be used in incremental backup strategies – where only new or modified files are added to the archive. Gzip compression reduces the overall file size, which makes it more efficient for distribution, backup, and storage purposes. It just bundles files & directories together while preserving their file structure and metadata. This means it takes all the specified files and puts them together into one container. Then we’ll jump into the step-by-step process of unzipping on both Linux and Windows platforms. 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.