Open tar gz files linux

Linux: How to open tar.gz file

This post is a quick instruction on how to open tar.gz files in Linux.

So you came across a file that has the extension .tar.gz and have no idea how to open it. Let’s say you downloaded node-v0.4.12.tar.gz , here’s how you open it.

$ tar -zxvf node-v0.4.12.tar.gz . $ ls -la drwxr-xr-x node-v0.4.12 -rw-rw-r-- node-v0.4.12.tar.gz

In the above example tar -zxvf will extract the contents of node-v0.4.12.tar.gz to a directory named node-v0.4.12 . Do whatever you want to do with the contents. Now it is at your mercy!

tar.gz is actually a «double-formatted» file type.

The .tar part indicates that it’s an archived file (multiple files bundled together), the .gz part indicates that it’s a gzipped f ile (the files are compressed to decrease file size). Further details about the .tar and .gz can be found from the links at the references section.

The Linux tar command has got many more options, find out what they do. Type tar —help or man tar at the terminal.

References #

  • Linux: Delete non-empty directory How to recursively delete a directory forcibly in Linux You probably know that rmdir is the bash shell command to delete directories in Linux. But the command will delete the directory only if it is . Mar 3, 2010
  • Linux: zip and unzip commands How to zip and unzip files in Linux To create «.zip» files in Linux, you use the zip command. To unzip «.zip» files, you use the unzip command. Here are some common uses of the zip and unzip commands. Mar 3, 2010
  • rsync: Tutorial with examples Need a fast and efficient way to synchronize files on two systems? Looking for an alternative to FTP / scp / rcp? rsync is the right tool for it! rsync’s syncing capability makes it an excellent alte. Jul 10, 2012

Источник

How to Open Tar file Linux

There are multiple files available on the internet which are downloadable for Linux but compressed as a tar file. Tar files store different files and squeeze them to keep the space and bandwidth in the downloading procedure.

These tar files work like a portable container to store various files, and it is also known as a tarball. However, many people can’t find out how to open a tar file in Linux, so you also want to learn how to open tar files and then read our article. This article will cover complete information on how to open tar files in Linux without facing errors.

Читайте также:  1 января 1970 linux

How to Open Tar file Linux

tar Utility

Let’s consider that we want to extract and open a doc file, and then we can use the below command to unzip the file on Linux:

Remember that the tar.gz file is a combination of the .gz and .tar files, so it is an archive file with other files.

As you can see in the above command, we have used xvzf because these have specific meaning and instructions for the system, and they are:

  • x: This command instructs to extract the files from a particular zip file.
  • v: This command stands for verbose that works to list out the files
  • Z: This command instructs to decompress the files.
  • F: This command instructs the filename on which you want to work.

In case you want to create the tar.gz file, then use the following command:

The doc file is available in the document directory, so we have used Documents at the last of the commands.

In case you want to add various files to the tar file, then execute the following command:

In the above command, we have used cvf, so “c” where c is used to creates a new archive.
Finally, use the below command to extract a tar file in Linux:

gzip Utility

First, we will describe the procedure to extract or compress the Tar file on Linux:
Open the Linux terminal and execute the following command to compress the file as tar:

In the above command, we are compressing the xyz.txt file as a tar.gz file. After squeezing the file, use the ls to confirm that the file is compressed successfully.

For extracting the xyz.txt file, you can execute the following command:

Finally, execute the ls command to confirm the file’s extension.
In case you want to compress all of the .txt files in a specific directory, then you can type:

In the above command, “*” is a wildcard for ” number of any characters.” Remember, this command can work on filenames with a specific extension .txt. You can use this way for all file types that include .jpg, .doc, and gzip.txt.

Читайте также:  Arch linux plasma discover

Conclusion

This is how you can easily extract and open tar files in Linux without any errors. As we have mentioned earlier, tar files store the files in a compressed manner, so you have to extract these files for using them. The above procedures are tried and tested on multiple Linux machines, but you have to follow all of these steps carefully.

About the author

Simran Kaur

Simran works as a technical writer. The graduate in MS Computer Science from the well known CS hub, aka Silicon Valley, is also an editor of the website. She enjoys writing about any tech topic, including programming, algorithms, cloud, data science, and AI. Travelling, sketching, and gardening are the hobbies that interest her.

Источник

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:

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.

Читайте также:  Astra linux capabilities parsec

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