LinuxTechLab.com
Originally published on
LinuxTechLab.com
One of the most performed functions during day to day activities of a system admin is
data archiving or data compression/Decompression. And normally we use tar
command to do so but there are other options as well for data archiving or extraction,
but that the tutorial for another time. In this tutorial, we are going to discuss Tar
command & the various actions we can achieve using it All these commands will work on
most of the Linux distributions.
TAR Command
It is certainly the most popular & widely used command for compressing or
decompressing files. It has integrated compression & create an archive with .tar
extension & we can then also use compress it with gzip or bzip2 compression method.
Lets discuss some examples,
here, -z option used with above mentioned command will help us create a Gzip
compression based archive. Also notice the change in the output file extension, it will
now be .tar.gz or tgzinstead of only tar.
Creating a compressed Bzip2 based archive
Now for some reason if we want to create an archive that used Bzip2 as the
compression method, then we can use the following syntax to create a compressed
archive
Here, -j option will create a Bzip2 based tar archive & the resulting output file extension
will be tgz2or tar.bz2
Here, input1, input2, input3 are the various directories or files that needs to be
compressed.
We use multiple exclude to exclude multiple files & directories, we can also exclude a
particular file type,
If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus
LinuxTechLab.com