Terminal Lesson 16
Hey guys, this is McKinson, one with another terminal lesson on how to tar things and compress things.
Now I've had a few complaints about tar because my last terminal lesson, I think it was, I showed you how to tar files, and people said, well, what's the point of this? Because I can just zip and it makes the files smaller.
So I'm just going to be showing you how to use tar to not only tar up a bunch of files but also to zip the tar file that you create.
I'm just going to CD to my desktop, and now I'm going to make a document on my desktop that's going to be an empty document, and then I'll show you what next.
Okay, so right here on my desktop is this file. If we take a look at this file right now, it's 4 kilobytes, 178 bytes. So now I'm going to use tar to make a compressed version of this that's going to be smaller than that.
The command is pretty much the same; it's tar -z cvbf
instead of just cvbf
. It's -z cvbf
space, then the name of the tar file, and that file is like file.tar.gz
. So you have to add the gz after it, space, and then the name of the file that you're compressing, which is file.txt
.
So now hit enter, and so here's my file.tar.gz
, which is a tar.gz of this file. Now notice this is 146 bytes, while this is 178 bytes, so this is actually smaller.
Now, let's compare that to zip. Right now we're just going to zip file.txt
. So right here is the zip; it's 181, and the tar is 146, which means that the tar is actually more efficient in this case than the zip.
I'm going to delete this file and just show you that this works when you untar; basically, it comes back up.
Okay, so now I'm going to show you how to untar this in terminal. You just type tar -zx vvf space file.tar.gz
, and that'll untar it through terminal.
So just remember to add the Z before the vvf to make it compressed, and remember it's tar.gz instead of just tar.
So that's how to make an archive with tar.
Thank you for watching. McKinson one, subscribe, and goodbye!