Tar is one most popular archiving utility for Linux. Tar is part of the util-Linux package and comes by default with almost all major Linux distribution.
When you download some tar file which has libraries to install, and you don’t know how to unzip or extract, Not an issue you clicked on the right article.
What is tar command?
The tar command utility helps the user compress or archive a file in a single file with a compressed size.
The tar command support number of compression program such as
If you are thinking why tar name assigned for creating archives, In earlier days we have to use magnetic tape to store the file, and for that reason, the name assign “tar”, and It stands for “Tape Archive”.
Before archiving or compressing a file, let’s understand what the difference between this two-term is.
Archiving is the process of combining one or multiple files into a single file; on the other hand, compressing is to reduce file size using compression technology.
Archiving multi file into tar using below command
$ tar cf compressed.tar file1 file2 file3
Compressing same file with gzippped archive.
$ tar czf compressed.tar.gz file1 file2 file3
Creating gzipped from a directory using it relative path.
$ tar czf target.tar.gz -C path/to/directory .
Extracting compressed or archived file into current directory using below command.
$ tar xf target.tar[.gz|.bz2|.xz]
If you want to change and extract file into another relative path pass below command without your respective directory path.
$ tar xf target.tar[.gz|.bz2|.xz] -C /home/trendoceans/Desktop
I have extracted into Desktop of trendoceans user in my system.
When you want to extract the tar file and remove the tarball file, pass the command.
$ tar xvf target.tar && rm -rf target
If you want to list file inside archived/compressed file without extracting it pass below command.
$ tar tvf target.tar
This command is used usually to create or extract tar file.If you have any query feel to free to ask in the comment section.