Unzipping tar gz in linux

How to Unzip (Open) Gz File

Gzip is a popular compression algorithm that reduces the size of a file while keeping the original file mode, ownership, and timestamp. This algorithm is often used to compress web elements for faster page loading.

By convention, a file compressed with gzip ends with either .gz or .z.

This article explains how to open (or unzip) .gz files.

Unzipping gz File #

On Linux and macOS, you can decompress a .gz file using the gzip utility. The syntax is as follows:

The command will restore the compressed file to its original state and remove the .gz file.

To keep the compressed file pass the -k option to the command:

Another command that you can use to decompress a .gz file is gunzip This command is basically an alias to file with gzip -d .

To open a .gz file with gunzip simply pass the file name to the command:

If you’re on a desktop environment and the command-line is not your thing, you can use your File manager. To open (unzip) a .gz file, right-click on the file you want to decompress and select “Extract”.

Windows users need to install additional software such as 7zip to open .gz files.

Extracting tar.gz File #

Gzip algorithm is designed to compress only a single file. Files that end in .tar.gz are .tar archives compressed with gzip.

To extract a tar.gz file , use tar command with the -xf options followed by the compressed archive name:

The command will auto-detect the compression type and will extract the archive in the current working directory .

Conclusion #

To decompress a .gz file, use the gunzip command followed by the file name.

If you have any questions, please leave a comment below.

Источник

How to Extract Tar Gz File in Linux — [Untar tar.gz]

This blog post will help you to get information about how to unzip tar.gz file, untar tar.gz file, and extract tar GZ file in Linux? Also, you can get a detailed guide to executing the overall process.

How to Extract Tar Gz File in Linux - [Untar tar.gz]

List of content you will read in this article:

What is TAR? [Definition]

TAR is an abbreviation for Tape ARchive. This command was primarily developed to fulfill the purpose of creating archives and storing the files on magnetic tape. Hence, the name Tape Archive.

The tar command helps you to generate several tar archives as it converts as many files as you want into archives. When we talk about the tar command, it can be used in ample ways. You can use it to add files to the archive, delete files, or extract tar archives. The list is pretty long.

Читайте также:  Linux starting postgresql service

Being a techie, it is highly evident that you are already familiar with the .tar.gz files.

These files are commonly known as ‘tarballs’. They are used by Linux, macOS, or even Windows users for backups or data archival.

Now, there are various methods to compress tar files. One of the most used methods to compress a file is Gzip. Moreover, whenever you compress the tar archive with gzip, it ends with .tar.gz or .tgz extension.

Besides, if you are a Windows user, you may need to download the 7zip tool to extract tar.gz file in Linux. A lot of such third-party applications are also available in the market. They do come with a drawback, that is, they do not work every time.

In this article, we are going to make you familiar with some ways to unzip/untar/extract tar.gz archives in both Linux and Windows.

How to extract tar.gz file in Linux?

It is a simple process to extract tar.gz file in Linux.

Before that, take a look at the meaning of these symbols:

1. x: This option is used to extract the files.

2. v: It means Verbose. It helps to list the files in the archive.

3. z: This is used to uncompress a file.

4. f: You can easily keep a name for the file by using this option.

To start with, if the file is compressed by a gzip compressor, you can apply the following command:

In this command, filename.tar.gz is the name of the archive that you want to unpack tar.gz file. Additionally, if you want to seek more information about the files, you may use the -v option. Here, -v stands for Verbose. Take a look:

Easy, right? But somehow if your work impedes and you don’t get the desired results, follow another method.

How to unzip .tar.gz file without gzip?

Follow the below-given procedure to unzip .ta.gz file without gzip command.

$ tar xvzf file.tar.gz -C /path/to/somedirectory

Here, -C is used to mention the particular path to store the file.

  • The next command is to extract a .doc file from the .tar.gz file. Take a look at the command below:

$ tar -xvzf file.tar.gz test.doc

tar -xf archive.tar.gz file1 file2

  • This command is specifically used for files. If you want to extract some directories, use the following command:

tar -xf archive.tar.gz dir1 dir2

Sometimes you get an error message like this:

tar -xf archive.tar.gz README

It implies that the files that you want to extract don’t exist.

  • Moving on, if you want to list the content of your tar.gz file, then use the below-mentioned command:
Читайте также:  Netstat linux install ubuntu

Well, these were some of the commands to extract tar.gz files in Linux.

The next segment talks to you about extracting tar.gz files in Windows. Let’s see how!

How to untar tar.gz files in Windows?

If you are a Windows user, here are a few steps for you to follow so that you can easily extract/untar tar gz file.

Step 1. Tap on Start on your Windows

Step 2. Now, go to the Command Prompt and click right. Choose Run as Administrator option

Step 3. Enter this command in the command prompt: tar -xvzf C:\PATH\TO\FILE\FILE-NAME.tar.gz -C C:\PATH\TO\FOLDER\EXTRACTION

You can add any desired path to store your files. After you press enter, all the files will be extracted to the path that you mention.

If you do not wish to use the command line method, don’t worry. There is another solution. You can simply head towards the File manager and click right on the file that you wish to extract. Choose the Extract option.

Conclusion

In a nutshell, tar.gz files or tarballs are used to archive data and backups. It is necessary to decompress and extract these files in order to get your work going.

There are specific ways and methods to conclude your task through various steps and commands.

As you have seen, this article assists you to extract tar.gz file [unzip tar.gz file, untar tar.gz file], whether you are a user of Linux or Windows.

We hope that the information provided in this article helps you in the best possible way.

Keep learning. Keep evolving.

People are also reading:

Источник

How to Extract or Unzip tar.gz Files from Linux Command Line

A tar.gz file contains several compressed files to save storage space, as well as bandwidth during the downloading process. The .tar file acts as a portable container for other files and is sometimes called a tarball. The .gz part of the extension, stands for gzip, a commonly-used compression utility.

In this guide you will learn how to extract or unzip files from tar.gz files using command-line in Linux.

tutorial on extracting files using tar.gz from command line

  • Access to a command-line/terminal window
  • The tar utility (included by default)
  • The gzip utility (included by default)

Extracting tar.gz Files in Linux

Using gzip Utility

Gzip by default, extracts the file in the current directory. In this example the file is located in the Documents directory.

Below, we have used the file named test.txt. Use the name of the file you want to compress instead.

to compress a single file with gzip enter the command in your terminal window:

After zipping the file, enter the command ls to confirm that the file has been compressed. The output confirms that the file now has a .gz extension.

confirming that the file has been compressed

To decompress a file, use the gunzip command:

Читайте также:  Localhost in linux mint

Again, use the ls command to confirm the extension of the file.

example file has been unzipped

To compress all the .txt files in a particular directory, type in:

The * sign is a wildcard, which means “any number of any characters.” This command would work on any (and all) filenames with the extension .txt.

This technique can be used on other file types including gzip.txt, .jpg, and .doc.

When you run gzip on multiple files at once, the system generates a compressed copy of each file. This can clutter up a directory quickly! Fortunately, there’s another tool to manage multiple files at once.

Using tar Utility

A tar.gz file is a combination of a .tar file and a .gz file. It is an archive file with several other files inside it, which is then compressed.

You can unzip these files the same way you would unzip a regular zipped file:

output in the linux terminal when extracting a tar.gz file

The basic command is tar , followed by four options:

  • x – instructs tar to extract the files from the zipped file
  • v – means verbose, or to list out the files it’s extracting
  • z – instructs tar to decompress the files – without this, you’d have a folder full of compressed files
  • f – tells tar the filename you want it to work on

To list the contents of a .tar file before you extract it, enter:

To instruct tar to put the extracted unzipped files into a specific directory, enter:

tar –xvzf documents.tar.gz –C /home/user/destination

how to unzip a tar.gz file to a specific destination in Linux

To create a tar.gz file, use the following command:

tar –cvzf documents.tar.gz ~/Documents

Similar to the tar command, it condenses all the content located in the /home/user/Documents directory into a single file, called documents.tar.gz. The addition of the –z option is what signals tar to compress the files.

To add multiple files to a tar file, use the command:

tar -cvf documents.tar ~/Documents

This copies the contents of your Documents folder into a single file, called documents.tar. The options -cvf work as follows:

  • c – creates a new archive
  • v – verbose, meaning it lists the files it includes
  • f – specifies the name of the file

To extract the files from a .tar file, enter:

This command extracts and lists all files from the documents.tar file. The -x option tells tar to extract the files.

Command that extracts all files from a zipped document

You can also use xargs with tar to create a tar.gz archive and populate it with files from the find command.

Note: Some graphical interfaces include a tool for managing tar.gz files without the command-line. Simply right-click the item you want to compress, mouseover compress, and choose tar.gz. You can also right-click a tar.gz file, mouseover extract, and select an option to unpack the archive.

This tutorial explains how to use the tar tool, the gzip tool, and how to utilize them together to work with tar.gz files. You are now ready to extract or unzip any tar.gz file.

Источник

Оцените статью
Adblock
detector