How to extract archive file in Linux

To extract archive file in Linux, you can use the tar command, used for extracting content from the archive files. “tar” stands for tape archive, which is used to create, maintain, modify, and extract files that are archived in the tar format.

Syntax:
tar [options] [pathname]

Following options are widely used with tar utility

A, –catenate, –concatenate Append tar files to an archive.
c, –create Create a new archive.
d, –diff, –compare Calculate any differences between the archive and the file system.
-v, –verbose Operate verbosely.
t, –list List the contents of an archive.
x, –extract, –get Extract files from an archive.

Refer below tar examples:

#Create a new tar archive.
$ tar cvf linux_archive.tar dirname/

Note: In above example, c means create a new archive, v means verbosely list files which are processed and f means following is the archive file name

#Extract from an existing tar archive.
$ tar xvf linux_archive.tar

#View an existing tar archive.
$ tar tvf linux_archive.tar

#To estimate the tar file size ( in KB ) before you create the tar file.
$ tar -cf – /directory/to/archive/ | wc -c
O/P: 20480

Leave a Reply

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