hello my name is gary sims and this is
gary explains and one of the common
formats that we use for transferring
around files across the internet moving
for backups is the dot zip file and
there are some variations on that
including the
seven zed for seven zip files and on
linux and unix you kind of might use tar
files with a gnu zip now in today's
video i want to look at how you handle
zip files and dot 7 zip files and tar
and
gnu zip files are inside of linux both
on the command line and using the
desktop so if you want to find out more
please
let me explain
[Music]
okay so here we are on the linux desktop
in this case it's ubuntu 18.04
and i've opened up the file manager
that's the one here on the left hand
side that you just get by default
and here we see three different types of
files piccolo osv 1.0 is a zip file and
that contains all the source code for
piccolo os
piccolosv1.tar.gzs that's a tar file
that's been compressed using a gnu zip
gzip and then i have a folder called my
stuff which you could be using backing
up whatever you want to back up photos
files
media whatever it is and inside here
there's a whole bunch of files also
another sub directory with more files in
it so we can see there's multiple levels
now to unzip a zip file that you've
downloaded really really easy you right
hand click and then you go extract two
and there are two options extract here
will create a folder based on the name
of the zip file and then extract all the
content into there so extractor here
it's created a folder called piccolo osv
one exactly the same as the file name
but without the dot zip and then inside
of that you'll find the content of the
actual zip file if you want to choose
where you want to put it you right hand
click on it go extract two dot dot dot
we then can create a new folder here
let's call it just
piccolo
and then we say
extract it all to there and here you can
see it's been created and now inside of
that you find the contents of the
zip file so very very simple you can
choose wherever you put them let's just
tidy up here a bit get rid of those two
same with the tar.gz file extract here
and it will uncompress it and unpack the
tar files remember the tar file is the
archive and the dot gz is the
compression and then inside here again
we find all the files that we need there
very very simple let's just tidy up a
bit here get rid of that now if you want
to compress something here's your my
stuff folder you want to compress some
stuff in it right hand click and all you
say is click compress what name do you
want to call it my stuff do you want a
dot z do you wanna uh dot zip so do you
want a tar dot xz that's a different
type of compression that we're not
covering in this video or a seven zip
one let's create a seven zip remember we
have a look at that uh we can try to
unpack it so you hit create there you go
it's now created that file and it's now
recognized as a 7-zip file if you
right-hand click you can do extract to
dot dot lot let's just make another
thing called
my stuff to
to not make it any different there we go
and it gets extracted into there and as
you can see it's got all the same files
in it so from inside of the file
explorer it's really really easy to do
literally right hand click and then just
choose how you want to extract the files
you can create files you can unzip them
all here really really simple
okay so here we are on the linux command
line the first thing we need to do is
make sure we have all the right tools
installed most of them are installed by
default just to be super sure sudo app
installed uh zip unzip gzip and pzip
dash full that's the full version of
7-zip i've already got them installed so
it's just going to say they're already
at the newest version which what they've
done now once they've installed we now
need to do some things with some zip
files now here i have a directory and
i've got three things in here one is a
copy of my
piccolo os that's for the raspberry pi
pico i do recommend you check that out
and the videos are made for it it's all
the source code in a zip file here is
the same stuff in a dot gz file we'll
talk about that and here is another
directory of some other stuff we want to
create some zip files so we're going to
talk about that so let's assuming you've
downloaded the zip file with something
in it in this case the source code but
it could be course b anything what are
the first things you need to do well the
first thing that i always do is if i use
unzip so that's a very simple command
minus t for test that test to make sure
that everything is correct that the file
has no corruptions in it so i'm then
just putting unzip minus t piccolo
osv1.zip and that will then create a big
long listing as you can see every one of
these files says okay okay okay at the
bottom no error detected so that's
listed kind of all the files are there
and we can see these different files
from the source code and it's told me
that everything is uh okay
now if you want to unzip that now notice
here we've just got these three things
we just do unzip piccolo
zip file and it will go ahead and it
will do it look it says extracting
inflating extracting and fading because
remember a zip file is both a
compression tool and an archiving tool
so it has to inflate it that's to
decompress it and it has to extract it
remove it from the archive and now when
we look here we can now see there is
this folder piccolo os
main so that unzipped it into there and
that was because if you remember when we
do an unzip minus t when we look at it
okay all of the files start with that
everything's inside that folder so
that's the way the zip file was created
so everything got put into that folder
and if we actually go into it
we can just see here now all the
different files in there absolutely fine
okay
now if you didn't want to put it into
that piccolo osv one dash main folder
what we can do is uh uh unzip minus d
for directory and then we'll just create
a directory called piccolo and then you
give it the name of the zip file that
you want to unzip and now if you notice
it's put everything in piccolo slash and
then all the other stuff inflating
extracting as you go along so again if
we look now here we can now see there is
a folder called piccolo and if we go
into there
we can see that it's exactly got the
piccolo os folder into it which is where
of course everything was stored inside
the zip file and then it's got all of
the source code in there so that's how
you unzip things now one quick one quick
extra tip if you find that that
unzipping is too noisy then what you can
actually do is you can do a minus q for
quiet option
okay and then we'll put in the name of
the zip file we're in unzipping it again
into the directory called piccolo but
now it'll be much quieter look at that
no no fast no listings on the screen
there but we can see that the piccolo
directory is there with all of the files
in it okay so i've reset things again
now there's another tool seven zip seven
zed that works uh with its own
compression technique which is slightly
better than the one probably for the
normal zip file but it also handles zip
files so if we do a seven zed and then t
for test
and then again we look at our piccolo
zip file as the same thing it now says
this is everything here everything
everything is okay it's tested it and
it's everything is okay but it didn't
list
the files in there if you want to list
the files in there we do exactly the
same thing but change the t to an l for
list
and then it lists all the files in there
again we can see it's the piccolo osv
one main folder and then all the files
are inside of it and it tells you here
all about the statistics of the files
and everything is okay so uh so you can
use the t for test l for
zip
l for this sorry and in fact you can use
x for extract so if we do this it will
extract everything and now here we can
see we have again that piccolo osv one
main folder and we can go in there and
again see all of the files now if you
want them to be extracted into a
different folder you again need to use x
for extract and then you use a minus o
for output now without a space this is
interesting don't use spaces in here
keep it stuck to it we just write here
piccolo it will be in now the folder
piccolo not oh picker those minus over
output and then piccolo and then we can
use
piccolo.zip here and it will extract it
all and now when we have a look we can
see there is now this piccolo folder as
well because we've extracted it to there
now 7-zip has the opposite problem to uh
zip is it doesn't really tell you much
tools if you want to see it kind of
extracting the things you use minus bb
uh don't ask me why i thought about it i
thought about minus b i don't know why
but there you go minus bb and it will
give you some information about what
it's doing along the way and there you
go you can see it extracting all the
files so if you like that kind of output
i always like that because it kind of
gives me the insurance that it's
actually working rather than looking at
this kind of command line just flashing
cursor as i'm waiting for but that's
just me so there you can get some output
about what's going on
okay i've reset things again now if you
ever have a dot gz file
okay it would normally be associated
with the tar file some of this is a tgz
so you can press this down
compress this down ha ha and it's a
pattern there you reduce this from tar
dot g to t g z tg z okay to be a com tar
now the thing about
g zip and g under which is gnu zip and
gnu unzip is it's not an archiving so it
only can just compress one file or
uncompress one file so you need tar to
do the archiving part and can use it to
do the uh uh the compression part so we
just basically do a gun zip gnu unzip
piccolo osv one tar dot gz you don't
need to do anything else what you'll
actually do is very different the other
ones it will actually remove the dot gz
and just give you the tar file so it
does it all automatically for you so
it's just removed it there and then just
for completeness i'll just show you if
you did want to extract that we weren't
going much into tar today maybe if you
think we need a separate video on how to
use tar
do let me know and i'll think about
making one but you do x for extract v
for verbose f for specifying the file
you want to use which in this case is
piccolo s.tar and that will then extract
it all there and again we can see we
have the same thing piccolo osv one uh
main file and that come from the tar
file there
now if you want to compress a file with
gnu zip then you do the opposite you
just do gzip
piccolo os v1.tar
and that will then do it and it will
automatically add the gz on the end so
notice that file here has now
disappeared and it's been replaced by
the version with the t with the gz so it
does the compression so that's how you
zip and unzip with uh gnu zip now if we
talk about zipping things up let's have
a quick look at that now i've got here a
folder called my stuff if you go into my
stuff it's just got some files it's got
another director underneath it called
other bits it's got some files it
doesn't matter what they are you could
be zipping up whatever it is that you
want to zip up your source code your
pictures your music collection whatever
is a backup whatever it is you're doing
so the way you create a zip file from my
stuff is you say zip
minus r for recursive because you want
it to go into all those directories and
then we're going to call it my stuff
oops sorry mr space there my
stuff
oh if i could type it would help dot zip
and then what do you want to zip up we
want to zip up that folder my stuff so
simple as that zip minus r for recursive
the name of the file you want to create
and then the name of the files or the
folder that you're trying to compress
that will go ahead and add everything
that's inside of my stuff into a here we
go look at that a zip file called
mystaff.zip and as you know we could do
an unzip uh minus t to check that uh and
there you go everything is okay and it's
got all those files in it as we expected
okay so that's how you do that if you
want to do it with 7-zip you seven
zed as we did before a for add add to an
archive again minus r for recursive
my stuff
we're going to do now
dot 7 z that's the default uh
extension for seven zip files and then
again my stuff
okay and that goes ahead and add in all
those files you can see it's going
through them one at a time boom boom
boom boom boom boom boom and at the end
of it we'll have a dot 7z file let's
have a look there we go
8.7 zed file and as before we could also
then do you know eight seven ah seven
zed
list
uh my stuff dot seven zed and there you
go distinct all that stuff so that's it
so we've been able to uncompress and
compress using zip unzip seven zip uh g
uh gzip gnu zip gnu unzip and also a
little bit of tar there to show you how
you can do all that all from the command
line
i hope you enjoyed that tutorial if you
did please do give it a thumbs up if you
like these kind of videos why not stick
around by subscribing to the channel
don't forget you can follow me on
twitter at
gary explains and i also have a monthly
newsletter go to gary explains.com type
in your mail address
no spam but you will get the newsletter
okay that's it
i'll see in the next
do
you