yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Terminal Lesson 18


4m read
·Nov 3, 2024

Hey guys, this is Maads. On and today I'm going to be showing you how, um, different methods of compressing, archiving, and doing both at the same time, and what good terminal commands that do these are.

So first of all, let's get this straight: compressing and archiving are two totally different things. Archiving is something kind of similar to what tar does. It takes a directory and turns it into a file, or it takes a file and turns it into a compressed file that you can then take the tar file of whatever you've tarred and move it somewhere else quickly and efficiently.

Compressing is when you use some kind of algorithm to smartly go into a file and find patterns and change those patterns into one simple pattern that never repeats; it just says it repeats. So that way, real files, um, get generated from them. It's turning um a file into a, um a real thing; it's turning a um file into a compressed version of the file that can be decompressed.

Now, let me explain things that do these. Zip, which is probably the one you're most familiar with, compresses and archives. Let me demonstrate what I mean. When you have a folder, you can zip it and it'll create one zip file for the folder that is smaller than the folder was. So it compressed and archived.

Tar just archives; it takes a folder and turns it into a file or something like that. Gzip just compresses. You've probably never heard of gzip, but there's a command gzip which literally just takes a file and turns it into a .gz file. It doesn't do anything; it can't do anything with directories really.

So let me demonstrate all these commands. First of all, I'll CD to my desktop because um that's where all my files are. So now all I need to do is say I have this file file.text. First, I'll zip it. By the way, you should have watched other terminal lessons before this one. So here's a file.text.zip. It's 12 kilobytes, while the original file.text was 1,600 kilobytes. So as we can see, it really went in there and did a good job compressing and archiving this.

So say I have a folder and I have two files in that folder, okay? So now this folder has two items in it. Okay, so say I want to zip this folder. I just do a zip -r folder.zip folder. So now I have a zip of this folder, and then we have four items in this folder, but it comes out with one zip file. Then if I delete this folder and unzip this ZIP file, I have the entire folder back because it was not only compressed but archived as well.

So that's my zip. Say I want a tar. I'll just say here is my tar of this folder and it's one file for the folder. So if I delete the folder and untar the tar, here I have the exact folder back. But if I take a look at this, 1.6 megabytes, this is 1.6 megabytes as well. So it's practically the exact same size, even a little bit bigger.

So why does this happen? Well, if you take a look, we open this up with text edit. I'll just use Taco right here. We actually have the contents of the files directly inside of this, as you can see, because tar doesn't compress. So the reason that people don't just have tar files sitting around anymore is because they waste space when you could compress them.

So let me just gzip this folder and show you why gzip has nothing to do with archiving. Type gzip -r folder. Watch this! Now I've gzip this folder; the folder is still there. There's no folder.gzip. When I open it up, every file inside of it is gone, and instead there are gzipped versions of the files that within them contain the actual files.

So how funny is that? I think that's pretty funny the way that gzip works. Um, so gzip ultimately just compresses, not archives. So the way to use tar and gzip to archive and compress is obviously to make a tar of whatever and then gzip that tar. So you do gzip space and then the tar file.

So here's the tar.gz. Here's my folder, so tar.gz. There's an easier way to do that; you just do tar -czvf folder.tar.gz. Yeah, whatever folder, and I'll delete this.

Okay, so here, tar can also do this. So if you watched my other terminal lessons, you'll probably be comfortable with what I'm doing here. But gzip is obviously just for compressing. But I like gzip more, actually, because it can just be used in a flat way. I can take one file, gzip it, and send it to my friend with a practically simple as hell terminal command.

So gzip is a good way to just take files and make them smaller. Tar is a good way to take files and make them into one. And zip does both most conveniently because you can just, on a Mac, right-click on something and click compress and you come out with a zip.

So that's just my opinion on compression methods. I will point out that gzip is used on stuff like HTTP compression, which can use gzip. So gzip is very important, basically.

Um, so gzip, the command is gzip -r folder or gzip file. So that's how to use gzip, and that's, um, what compression and archiving is.

So thanks for watching. Maad, one, subscribe and goodbye.

More Articles

View All
Subtracting vectors with parallelogram rule | Vectors | Precalculus | Khan Academy
In this video, we’re going to think about what it means to subtract vectors, especially in the context of what we talked about as the parallelogram rule. So, let’s say we want to start with vector A, and from that, we want to subtract vector B. We have v…
Where Is The U.S Dollar Heading? | Stansberry Research
[Music] [Applause] [Music] Please welcome back Kevin O’Leary, star of ABC Shark Tank, aka Mr. Wonderful. Kevin, always good to see you. Great to be here! Thank you so much. Yes, it’s really interesting times in the market, just insane times right now. …
Why Their Story Matters | The Long Road Home
We all should be aware of every single person who dies fighting for our freedom and democracy around the world. Where we’re going, Sadr City, over two million people lived under a dictator’s boot for 24 years. And we can build a better future for them, f…
There's no such thing as Universally Preferable Behaviour
Universally preferable behavior is the name of Stefan Malan’s book arguing for an objective non-religious foundation for morality. Uh, I’ll begin by saying I don’t believe that anything that could fairly be called objective morality exists. Uh, so catego…
Who Is Responsible For Climate Change? – Who Needs To Fix It?
Since the Industrial Revolution, humans have released over 1.5 trillion tons of carbon dioxide or CO₂ into the Earth’s atmosphere. In the year 2019, we were still pumping out around 37 billion more. That’s 50 percent more than the year 2000 and almost thr…
Finding specific antiderivatives: rational function | AP Calculus AB | Khan Academy
So we’re told that ( F(2) ) is equal to 12. ( F’ ) prime of ( x ) is equal to ( \frac{24}{x^3} ), and what we want to figure out is what ( F(-1) ) is. Alright, so they give us the derivative in terms of ( x ), so maybe we can take the antiderivative of t…