Avançar para o conteúdo

How to Compress and Extract Files Using the tar Command on Linux

how to unzip a tar.gz file

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. 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.

how to unzip a tar.gz file

Extract Files to the Specific Directory

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. In the option box that shows up, comprar compound governance token choose how and where you want to unzip your tar.gz file. If you have an existing tarball and want to add a new file into it, you don’t have to unarchive everything just to add a new file. To extract a single file, provide the path and the name of the file.

  1. Technical details aside, all you need to remember is that .zip files are more accessible but less space-efficient, while .tar files are less accessible but more space-efficient.
  2. List the files in the directory with ls and you’ll see that a directory has been created called Ukulele Songs.
  3. Since .tar.gz compresses multiple files all at once, it can take advantage of similarities between individual files to save on space.
  4. 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.

Looking Inside Tar Files Before Extracting Them

The biggest advantage of tar.gz files is that they are more compact and easier to handle than other compressed archive formats. If the file is a turnkey forex reviews read customer service reviews bzip2-compressed file, replace the “z” in the above commands with a “j”. Use the following command to compress an entire directory or a single file on Linux.

Now the file “four” is extracted to a new directory called “bar.” If “bar” already exists, then “four” is dollar to bitcoin chart how to transfer from coinbase to binance placed inside the existing directory. 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.” The -p (parents) option causes mkdir to create any parent directories that are required, ensuring the target directory is created. As the files are extracted, they are listed in the terminal window. Once you’ve selected the right file, you’ll see “7-Zip File Manager” show up in the select app dialog.

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. 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.

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. 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.

How to Extract or Unzip .tar.gz Files in Linux

The GNU tar command included with Linux distributions has integrated compression. It can create a .tar archive and then compress it with gzip or bzip2 compression in a single command. That’s why the resulting file is a .tar.gz file or .tar.bz2 file. You’ll encounter them frequently while using a Linux distribution like Ubuntu or even while using the terminal on macOS. Here’s how to extract — or untar — the contents of a tar file, also known as a tarball. Like the tar utility, gzip also allows you to zip and unzip multiple files or entire directories at a time.

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. 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.

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *