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. After reading this article, you know how to extract or unzip .tar.gz file in Linux using different methods and tools. It also integrates with the Windows Explorer context menu, which enables users to create and extract archives directly from the right-click menu.
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. Then I used tar xvf (extract, most encrypted messaging apps are vulnerable to side-channel attacks! verbose, file-archive) to unpack the contents here.
- The files will be extracted to the selected location.
- Files from the ignored directories are still extracted, but the directory structure is not replicated on your hard drive.
- Right-click the first result and select the “Run as administrator” option.
- This option is supposed to only add the new files according to help docs, but in my practice, it worked the same as append, adding new copies of all the files.
- 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.
Here’s how to extract — or untar — the contents of a tar file, also known as a tarball. While gzip compression is most frequently used to create .tar.gz or .tgz files, tar also supports bzip2 compression. This allows you to create bzip2-compressed files, often named .tar.bz2, .tar.bz, or .tbz files. To do so, just replace the -z for gzip in the commands here with a -j for bzip2. 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.
Using the command line (cmd)
If you’re not comfortable 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. However, tar was unable to find FILE within .tar.gz, meaning that the user either misspelled the name or that the file simply doesn’t exist in filename.tar.gz. Another common cause of errors is case sensitivity, where Linux treats “FILE” and “file” as two separate entities. If the command line isn’t your thing, there are plenty of user-friendly tools available to unzip tar.gz files.
Refresh the basics: Archive vs Compression
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. Someone somewhere is probably still using tar with tape.
Getting Started With Tar Command
Tar stands for “tape archive” and refers to a practice from the earlier days of computing when data was backed up to tapes. Despite the nostalgic origin of the name, tar is very powerful and uses modern technologies to archive and compress files. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line. Notice that we don’t need to use the -z option to list the files.
Run the info tar command at the shell to view the tar command’s detailed information page. Press the q key to quit the information page when you’re done. If the file is a bzip2-compressed file, replace the “z” in the above how to buy icx commands with a “j”.
For this article, I want to demonstrate some of the common methods for archiving and compressing files using tar. 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. To extract a single file, provide the path and the name of the file.
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. And now you can use the 7-Zip File Manager to open, view, or extract files from tar.gz and other archives. 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.
Here is a complete list of the documents that will be used. For more information and to schedule a live demo, contact a hosting expert from Kinsta today. Once you choose the directory, click the Select button in the top right corner.
Gzip is also more common, with some stripped-down Linux systems including gzip support what is bitcoin mining 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. You can easily unzip the resulting .tar.gz file with the decompress (-d) option.
You can use the -t option (instead of -c) to view the contents of an archive file. This works the same whether the file is compressed or not. It will list the actual file size, not the compressed size. While tar itself cannot compress files, you can use one of the common compression algorithms to compress the files while creating a tarball. I’ll show you how to do that later in this basic tar tutorial.