Technology and General Blog

Though working with Linux, you may possibly have discovered that several packages occur with a “.tar” file extension. So, what is a tar file? A tar file is a assortment of several information into one particular file. Tar (Tape Archive) is a plan that collects the documents and grabs some valuable details about documents it archives, such as permissions, dates, and many others. It is noteworthy that the Tar utility does not compress the documents for compression, you want “gzip” or “bzip” utilities.
As a Linux administrator, you typically have to deal with tar documents. In numerous cases, you have to extract the info of a tar file to some certain directory. So, how to extract the tar file to a individual route? One particular way is to extract the tar file in the recent directory and then duplicate it to the sought after directory. It will do the job, but the method is time-consuming. This guide is focusing on obtaining alternatives to extract many sorts of tar data files to a certain directory.

How to extract Tar file to a unique directory in Linux:

To extract the Tar file to an additional directory, adhere to the down below-talked about syntax:

$tar -xf [file_name].tar -C [/path_of/directory]


$tar –extract –file=[file_name].tar –directory [/path_of/directory]

The “-x” flag tells the Tar utility to extract the file outlined in the argument right after “-f.” Whilst, “-C” flag is used to set a specific directory to extract the file. Alternatively, you can explicitly point out the total text to extract files working with tar. In my feeling, using flags is a a great deal more rapidly way to extract data files than typing the full phrase. Let us do an instance I have a file by the name of “my_documents.tar,” which I want to extract to a directory “files/tar_files,” and to do that command would be:

$tar -xf my_paperwork.tar -C information/tar_files


$tar –extract –file=my_paperwork.tar –directory documents/tar_documents

If you want to check the progress of extraction of the file in the terminal, then use the “-v” (verbose) flag:

$tar -xvf my_paperwork.tar -C documents/tar_documents

How to extract “tar.gz/tgz” files to a distinct listing in Linux:

As mentioned earlier mentioned that tar documents can be compressed by utilizing the “gzip” utility. To extract this kind of data files to a precise directory, the treatment is rather much very similar an additional flag “-z” will be extra in the command to offer with “tar.gz” or “tgz” documents:

$tar -zxf my_documents.tar.gz -C information/tar_gz_information


$tar -zvxf my_files.tar.gz -C data files/tar_gz_documents

How to extract “tar.bz2/” data files to a particular listing in Linux:

Before we understand the extracting strategy, allows have an understanding of what “tar.bz2,,tbz,tbz2” data files are. These are the file extensions of the tar data files compressed by possibly the “bzip” or “bzip2” utility in Linux. To extract data files with any of these extensions, we will include the “-j” flag:

$tar -jxf my_documents.tar.bz2 -C documents/bzip_files

For verbose output use:

$tar -jvxf my_paperwork.tar.bz2 -C files/bzip_documents


Tar is a greatly utilised utility in Linux and UNIX-centered running units to make backup archives. Tar utility also arrives with a characteristic to extract tar documents to a particular listing. Documents can be extracted utilizing the “-C” flag with the specified folder route. What’s more, applying the Tar utility, you can also extract the specific files from the archived information. This all-in-just one utility has a ton to discover and to master a lot more about Tar utility execute “man tar” in the terminal.

Leave a Reply

Your email address will not be published. Required fields are marked *