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

Terminal Lesson 19


4m read
·Nov 3, 2024

Hey guys, is Mad Kids alone? Today's terminal lesson will consist of several great impressive things.

So first of all, the first most impressive one of these is sticky bits. Now, sticky bits is about running commands as root or their owner. With the sticky bit, if you set a sticky bit on an executable like RM, then you set the owner of RM to root. Whenever you run RM, it'll run as root. So I'm going to show you how to do sticky bits.

I'm also going to show you stuff about banner, and banner lets you take text on the screen and converts it to a bunch of hashes. It'll make text scroll across the screen sideways, or, you know, this way. So y'all have to turn your head sideways to read it, but it'll make letters bigger using hashes. You'll understand more about that when I show it.

The next one is just kind of like a fun thing that you can probably figure out anyway. It's making a bunch of texts come up and keep on repeating itself, like "Hello" would repeat again and again and again and again on the terminal screen really fast. So those are my three things I'm going to be teaching you.

I'll just point out that sticky bits is not a security issue because in order to make commands run as root, you have to, at one point or another, have been logged in as root. You can do all this stuff if you figure it out. So I'm gonna get started.

So first of all, the first thing I said I was going to be demonstrating is sticky bits. Let's say I have a command, and I'll just put RM on my desktop. Okay, so now RM is on my desktop, right? When I run RM from here, I can delete any files that are owned by me. But say if I was owned by root and I don't have permission to delete, wouldn't it be great if I could make this version of RM on my desktop always run as root?

Well, it's easy enough to do this. First of all, you want to change its owner to root. I'm not sure I showed this in another episode, but you do sudo chown root RM, replacing RM with the path of the file you want to change the owner to root. So now I'll type my password since I typed sudo.

Now, if I do ls -l RM, RM is owned by root. So now when I run RM, it'll still run and the normal RM is now owned by root as well. So now we're going to give it a sticky bit. For that, you do sudo chmod a+xs RM, so now if I keep ls -l RM, it has this s next to every single one.

Now when I run RM, it'll run as root. So I'll make a file on my desktop that I don't normally have permissions to delete, and I'll use this magic sticky bit to delete it. I've created a file on my desktop, it is locked, and I have no way to delete it. If I type rm file and hit "y", it won't let me delete it.

So I have the sticky-bitted RM on my desktop. If I said ./RM to run the RM on my desktop, space, file, the RM will run as root, and when I hit "y" since it was running as root, the file now is gone. So I ran RM as root without running a sudo command.

I can do this for practically any command, but some commands make sure that this doesn't happen. They have built-in security features such as su. A bunch of programs already have sticky bits, like passwd already has a sticky bit, because otherwise it wouldn't let regular users edit /etc/passwd.

So obviously, you're not going to give passwd a sticky bit and change the root password, so don't think you're going to be able to do that. But that's pretty cool. Now that I've showed you sticky bits, I'm just going to delete my RM.

Okay, so the next thing I said I was going to show you was banner. The command for banner is simple: banner Hello. Now it's pretty high in these huge letters, and it's hard to read, right?

So if you type banner -w 64 and then hit enter and type a message, "This is Joe," it writes. As you can see there, it's written "This is Joe" sideways, of course. So that's too bad, but it is sideways. If we do that and redirect it like echo "Hello" > file.txt, there we are. You can also type the message right here, so I'll type this and I'll say | more then I'll just type this.

Okay, so that is how to do that, and it's like scrolling text on the screen. I'm sure a lot of people still use that somewhere.

So the next thing I was going to show you is how to display random text on the screen and make it scroll up really fast, and it looks cool. You probably already understand kind of why this works if you watched our shell scripting lessons.

It'll take while (true); do echo -n " Hello "; done. Now I'll put happens. As you can see, this works. If you hold down a key, it looks a little weird like this; I'm holding down a key, several keys, dead stuff.

So I can press Ctrl-C to get out of it. As you can see, if I add another space before and after "Hello", it looks a little cooler. You can even add another sleep right here, so right after the semicolon, sleep 0.1. That way it goes a little slower.

You can see the keys I'm pressing. Press Ctrl-C. So this is a cool thing; it's not really a command, it's a set of commands. echo just prints something out to the console. echo -n prints something after the console without printing a new line.

So I'm not printing a new line; I'm just putting space. So as you can see, there are going to be four spaces between each echo, or yeah, between each "Hello." So that's cool.

So that's how to do some of this cool stuff like banner, sticky bits, and making random text scroll on the screen, even though the random text thing is not really a command. It's just something fun I figured out.

So thanks for watching Mad Kids on the one. Check out all these commands. I appreciate it if everyone would just do these commands. Thanks for watching, subscribe, and give up.

More Articles

View All
Average atomic mass | Atoms, isotopes, and ions | AP Chemistry | Khan Academy
The thing that I’ve always found amazing about chemistry is it’s an entire field of science that we as human beings have developed to actually understand what is happening at an almost unimaginably small scale. In particular, we’re going to be thinking ab…
We Fell For The Oldest Lie On The Internet
Look at this fun fact: Did you know that YOUR blood vessels taken together add up to 100,000 kilometers, enough to wrap them around the planet twice? One of our favourite fun facts, used in our book and app and a video and… wait… 100,000 kilometers is lik…
Inches and feet
In this video, I’m going to introduce you to two units of measuring length. The first is the inch, which you might have heard about. You’re probably thinking, “How long is an inch?” Well, if you’re familiar with a quarter, a quarter looks something like t…
360° Climbing Giants | National Geographic
[Music] [Music] My name is Wendy Baxter, and I have probably one of the coolest jobs on the planet. [Music] I get to climb in and study giant sequoia trees. My name is Anthony Ambrose, and I am a canopy biologist. I’ve loved trees and climbing trees my en…
The 6 BIGGEST advantages of being young in business
What’s up you guys, it’s Graham here. So, one of the topics that gets brought up so much on my channel are comments along the lines of, “Am I too young to get into business? Am I too young to sell real estate?” People are telling me I should wait till I’…
StarCraft II Guest Pass GIVEAWAY!!! GTA IV + SCII = ??????
Hey Vsauce, it’s Michael, and of course, Lucy. We have some really great news for you! I’ve been playing Starcraft 2 a lot the past few days. I’ve actually been playing The Lost Viking more than the actual game. I mean, that’s worth $60, right? Speaking …