How to untar linux

How to Untar Files in Linux?

All the Linux distributions offer the “tar (tape archive)” command line tool to create archive files. The “archive” file comprises one or more files and metadata. They are beneficial as they are easily portable and take less storage. Once the archive file is created, it can be untared or extracted using the “tar” command.

This guide provides the possible ways to untar files in Linux using the “tar” command.

The outcomes of this guide are listed below:

  • Untar the “tar” Format Files
  • Untar the “tar.gz” Format
  • Untar a “tar.bz2/.tar.zx/.tar.bz/.tbz/ or .tbz2” Files
  • Untar the Specific File
  • Untar Files Into a Particular Directory

Let’s start with the process to untar files in Linux.

How to Untar the “tar” Format Files in Linux?

The basic syntax to untar the tar archive in Linux is written below:

Syntax:

The above syntax holds the following components:

  • tar: Represents the “tar” utility.
  • x: Helps to extract the archive.
  • f: Tells the archive with the given filename
  • file_name.tar: Denotes the tar archive.

Example:

Let’s use this syntax to untar the “Sample.tar” tar archive file. This file is available in the “notes” directory as shown in the screenshot:

Use the below “tar” command to list down the content of the “Sample.tar” archive file:

To untar the “Sample.tar” archive into its PWD “notes” execute the “tar” command in the following way:

Run the “ls -l” command for the verification of extracted “Sample.tar” archive file:

The content of the “Sample.tar” archive file is extracted or untar into the “notes” directory. The archive file also remains to save in the “notes” directory.

How to Untar the “tar.gz” Format files in Linux?

A tar.gz archive is typically smaller than a regular tar archive because the gzip compression algorithm reduces the size of the file. The generalized syntax to untar the compressed archive is typed below:

Читайте также:  Remove yandex disk linux

The only difference between the syntax is the “z” flag to untar/extract the compressed archive file.

The compressed tar archive has a “tar.gz” extension. In this situation, the “Test.tar.gz” compressed located in the “Extra” directory has the following contents:

Now, type the tar command in the terminal to untar the “Test.tar.gz” archive file:

For the verification execute the “ls-l” command as shown below:

$ ls -l

It is verified that the “Test.tar.gz” is extracted or displaying the “Extra” directory that is compressed in it.

How to Untar a “tar.bz2/.tar.zx/.tar.bz/.tbz/ or .tbz2” File?

The tar archive compressed with “bzip2” follows the “tar.bz2”, “tar.bz”, “tbz2”, and “tbz” extensions at their ends. The generalized syntax to untar the “tar.bz2”, “tar.zx”, “tbz” compressed archives are written below:

The “-j” flag is used to extract the “bzip2” compressed tar archive files.

As the “Extra.tar.tbz” already created compressed tar archive in the “home” directory is displayed in the terminal:

$ tar -jcvf Extra.tar.tbz Directory1

Extract it into the “pwd” directory using the “tar” command:

The above command is successfully executed without any error.

Run the “ls -l” command for the verification:

The output verifies that “Extra.tar.tbz” content is extracted into the “home” directory.

How to Untar the Specific File/Directory in Linux?

The “tar” file also facilitates the Linux user to untar or extract the specific file/directory from the archive files. As the “test.tar” archive file contains the following content:

Use the “tar” command to extract the “FF.txt” directory from the above-shown list:

$ tar -xvf test.tar Dir1/D21/FF.txt -C

It is confirmed that the “FF.txt” text file is extracted into the present working directory. For more verification, use the “ls -l” command:

How to Untar Files Into Particular Directory?

It is not mandatory to untar the files in the same directory in which the archive file is located. However, the user can extract/untar the archive file into a directory. For this purpose, use the “-C” flag with the absolute path of the directory:

For “tar” Format Archive Files:

$ tar -xf file_name.tar -C /path/to/directory/

For “tar.gz” Format Archive Files:

$ tar -zxf file_name.tar -C /path/to/directory/

That’s how you can untar files in Linux.

Conclusion

Linux offers the “tar” command to untar archive files easily. The option “-x” of the “tar” utility is used to perform this task. Moreover, the “tar” command is also useful to untar the compressed archive files with the extension “tar.gz” and other compression formats. This post has described all the possible ways to untar both Files in Linux.

Источник

How to Untar Files in Linux

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.

How do I open a Tar GZ file in Linux?

  1. Open a console, and go to the directory where the file is.
  2. Type: tar -zxvf file. tar. gz.
  3. Read the file INSTALL and/or README to know if you need some dependencies.
Читайте также:  Установка web сервера на линукс

What is untar in Linux?

Most of the Linux files that can be downloaded from the Internet are compressed with a tar , tar. . gz and tar. bz2 compression formats and it is important to know how to extract such files. The following article will help you to extract (unpack) and uncompress (untar) – tar , tar.

How do I unzip a tar XZ file?

To extract (unzip) a tar. xz file simply right-click the file you want to extract and select “Extract”. Windows users need a tool named 7zip to extract tar. xz files.

How do I unzip a GZ file?

  1. Save the . .
  2. Launch WinZip from your start menu or Desktop shortcut. .
  3. Select all the files and folders inside the compressed file. .
  4. Click 1-click Unzip and choose Unzip to PC or Cloud in the WinZip toolbar under the Unzip/Share tab.

How do I split a Tar GZ file in Linux?

  1. $ tar -cvvzf .tar.gz /path/to/folder.
  2. $ split -b 1M .tar.gz “parts-prefix”
  3. $ tar -cvvzf test.tar.gz video.avi.
  4. $ split -v 5M test.tar.gz vid.
  5. $ split -v 5M -d test.tar.gz video.avi.
  6. $ cat vid* > test.tar.gz.

What is a TGZ file in Linux?

A TGZ file is a TAR Archive file that has been compressed using Gnu Zip (gzip) software. Commonly used on UNIX and Linux systems, TAR archives bundle a collection of files into a single file for easier distribution or backup.

What is the difference between TAR and GZ?

Tar is an archiver, meaning it would archive multiple files into a single file but without compression. Gzip which handles the . gz extension is the compression tool that is used to reduce the disk space used by the file. Most Windows users are used to having a single program compress and archive the files.

How do you untar in Unix?

  1. From the terminal, change to the directory where your . tar file has been downloaded.
  2. To extract or untar the file to the current directory, type the following, (Making sure to replace file_name.tar with the actual filename) tar -xvf file_name.tar.

How do you use untar?

  1. To Create a Tar file: tar -cv(z/j)f data.tar.gz (or data.tar.bz) c = create v = verbose f= file name of new tar file.
  2. To compress tar file: gzip data.tar. (or) bzip2 data.tar (slower but more efficient compression)
  3. To uncompress tar file. gunzip data.tar.gz. (or) .
  4. To untar tar file.

How do I copy directories in Linux?

To copy a directory, including all its files and subdirectories, use the -R or -r option. The command above creates the destination directory and recursively copy all files and subdirectories from the source to the destination directory.

How do I unzip a compressed XZ file?

The simplest example of compressing a file with xz is as follows, using the -z or —compress option. To decompress a file, use the -d option or unxz utility as shown. If an operation fails, for instance a compressed file with same name exists, you can use the -f option to force the process.

How do you extract and install Tar GZ file in Linux?

  1. Open your directory, and go to your file.
  2. Use $tar -zxvf program.tar.gz to extract .tar.gz files, or $tar -zjvf program.tar.bz2. to extract . tarbz2s.
  3. Next, change the directory to an unzipped folder:
Читайте также:  Установка gtk linux mint

How do I install an XZ file?

  1. Open a console.
  2. Use the command cd to navigate to the correct folder. If there is a README file with installation instructions, use that instead.
  3. Extract the files with one of the commands. .
  4. ./configure.
  5. make.
  6. sudo make install (or with checkinstall )

Installing Eclipse IDE on Debian 10

Eclipse

How do I download Eclipse on Debian?Can you install Eclipse on Linux?How do I download Eclipse on Linux?Where is Eclipse installed on Linux?How do I o.

How to Switch Between GDM and LightDM in Ubuntu [Quick Tip]

Manager

Switch between LightDM and GDM in Ubuntu Use tab to select your preferred one and then press enter, Once you have selected it, press tab to go to ok a.

How To Install Standalone oVirt Engine on CentOS 8

Ovirt

Network Interface: 1 Network Interface Card (NIC) with bandwidth of at least 1 Gbps.Step 1: Enable oVirt 4.4 and PostgreSQL Repositories. Update your .

Latest news, practical advice, detailed reviews and guides. We have everything about the Linux operating system

Источник

How To Untar Files In Linux?

How To Untar Files In Linux?

The *.tar is a popular archive format used to compress files in Linux and Unix operating systems. The tar format is used with different compression algorithms like gz, bz2, etc. The most important function of the tar format is the ability to store multiple files and directories as a single file where it can be easily compressed. In the tutorial, we examine how to untar files with different compressions algorithms like gz, bz2 etc.

Untar Command Syntax

The tar command has the following syntax which can be used to untar files and folders in different ways.

tar OPTIONS TAR_FILE PATH
  • OPTIONS is used to untar different compressions formats.
  • TAR_FILE is the tar file.
  • PATH is optional and used in the tar file is extracted differently than the current working path.

Untar tar File

A tar file can be untared or extracted with the following command.

Untar tar.gz File

The tar files can be compressed with the gzip as gz format. In the following example, we extract the tar.gz file.

Untar tar.bz2 File

The bz2 is another popular compression format where tar can be compressed with it. The *.tar.bz2 can be untarred like below.

Untar To Specified Path or Folder

The untar operation extract files to the current working directory by default. But we can also specify another directory to untar a tar archive. The path can be specified with the -C option like below.

$ tar -xvf nmap.tar.bz2 -C /home/ismail/Downloads/

List Contents of tar File

A typical tar file contains lots of files and directories. The contents of the tar file can be listed with the following command.

List Contents of tar.gz File

List Contents of tar.bz2 File

Untar Single File

A single file can be untared from a tar archive. The file which will be extracted is added after the tar archive file.

$ tar -xvf nmap.tar.gz nmap/capsule.c

Untar Specific Extensions

Files with specific extensions can be untar using the tar command. In the following example, we untar files with *.txt extension.

$ tar -xvf nmap.tar.gz --wildcards "*.txt"

Untar Files with Specified Pattern

$ tar -xvf nmap.tar.gz --wildcards "Cache*"

Источник

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