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
The Dilemma Of Loneliness
In the age of individualism (in Western countries at least), there is an increasing concern in regards to social isolation. We see this happening with the elderly, that are put away in retirement homes, deprived of interaction with children and grandchild…
Modeling with basic exponential function
There are 170 deer on a reservation. The deer population is increasing at a rate of 30% per year. Write a function that gives the deer population P of t on the reservation T years from now. All right, let’s think about this. And like always, pause this …
The Truth About My Coffee Company (I Screwed Up)
What’s up you guys, it’s Graham here! So, two years ago, I made the decision to start my own coffee company, and this video is a prime example of what not to do because I’ll admit I made some pretty stupid mistakes. For those unaware, the idea of starting…
Worked example of linear regression using transformed data | AP Statistics | Khan Academy
We are told that a conservation group with a long-term goal of preserving species believes that all at-risk species will disappear when land inhabited by those species is developed. It has an opportunity to purchase land in an area about to be developed. …
How To Be The Next Elon Musk According To Elon Musk
So, uh, one of the, I think, most common questions I hear young people, ambitious young people, ask is: “I want to be the next Elon Musk. How do I do that?” Um, obviously, the next Elon Musk will work on very different things than you did. But what have …
Angular momentum of an extended object | Physics | Khan Academy
[Voiceover] So we saw in previous videos that a ball of mass m rotating in a circle of radius r at a speed v has what we call angular momentum, and the symbol we use for angular momentum is a capital L. The amount of angular momentum that it would have wo…