Hey, welcome back to
this video.
So in this video we are going to learn about archives
and how you can compress files
and directories into
Linux.
We are going to see different compression techniques.
Also, we will see how you can zip
and unzip or extract those
archives.
So let's quickly begin with the first one so
First let's quickly go into our directory where
we are going to compress a directory. So
let's go and UFO net which is the directory in
which you can see. I have already created a
directory named Rohit. So
let's see what's inside it and you can
see there is a file which is hack dot txt
which contains the content or
the text which is I love hacking.
Alright, so let's go one step
back using CD Dot and now we are
back again in the UFO net directory. All
right.
so the first thing or the First Command that we are going to
see is tar
So basically we are going to create a tar
named archive, which is archive.tar which
will contain the directory which is Rohit
and for that the command that
we are going to use is tar compress.
f
archive dot tar which is the name that we are giving to
our archive and the directory that you want
to use or which you intend to
be compressed. All right, so we have finally compressed Rohit
directory into archive dot tar
now you can also decompress it
or you can decrypt it using the command which
is star x v f and
the tar name or
the compressed file name.
As you can see it has finally decompressed it
and you can see the content which is Rohit slash heart
dot txt inside it perfect.
Now let us move forward and now we are
going to see how you can create a gzip
compressed tar file, which is
a gun zip-based tar file. So for
that the command that we are going to use is star.
c z f
you can add The Hyphen or the
dash. It is not compulsory without it. Also
the command will work.
Alright, so tar c z f and archive
dot tar dot gz and
directory that we want to gunship or
compress is Rohit as you can see it is
finally created a gunship file,
which is archive dot our DOT gz
perfect.
So this was the second method or the
second way through which we can compress the
files. Now, let's quickly extract the
gunship or gzip files for
that. The command is star.
X z f and the archive
name which we have recently compressed and
now this will decompress it. Perfect. So
in case sometimes you download few files
from the Internet or there are some programs of
binaries from GitHub which may be gun
zipped. So this is the command through which
you can decompress it and finally use
it.
Perfect. Let's move forward and now we
are going to choose the same directory which
is Rohit again. But this time we are going to create
a tar file with B zip
to compression. Now. This is again
a new technique of compression that we are going to
use you may come across many times these types of
compressed files on GitHub and other various
websites. So that is the main reason
I'm showing you how you can create these types of
compressed files and if in case you have downloaded
it how you can decompress it.
Now to create a bzep2 compression you
simply have to type the command which is star
C J F and archive dot
tar dot b z 2
and the directory name which is Rohit perfect.
So we have successfully created a new
archive with bzep2 compression. Now
in case you want to decompress it the command
would be tar x j f
and archive dot r dot bz2 perfect.
This will decompress it again into
the original directory, which is Rohit.
So this is it for this video? I hope you guys understood three
methods to compress and decompress the
files. Thank you.