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
Stonehenge Has a Traffic Problem | Podcast | Overheard at National Geographic
It’s June 2021 at Alice Zoo, this National Geographic photographer. She’s in a field in rural England. It’s this gray, overcast English morning. It was still totally dark when we arrived. There were kind of a few other figures quietly making their way in …
Lead the Life You Want: A Big Think Mentor Workshop, with Stewart D. Friedman | Big Think
The problem with the phrase work-life balance is that it connotes tradeoff, right. So in the world of work/life balance it’s zero sum. Your work and the rest of your life. So you could be doing really great in your work – you’re getting more money, more …
The case against "good" and "bad" - Marlee Neel
(Music) Esteemed members of the jury, I submit the following words for immediate and violent execution and extraction from our vocabularies, to be locked away forever, if you would prefer. These words I present to you are “good” and “bad.” These words hav…
See Potala Palace, the Iconic Heart of Tibetan Buddhism | National Geographic
The centerpiece of Tibet’s capital Lhasa is the imposing Potala Palace. At 12,000 feet above sea level, it’s the highest palace in the world. It’s also a major center for Buddhist spirituality. Potala refers to a sacred mountain in India, and for centurie…
I got a CUSTOMIZED Credit Card from ZHC
Do you know about how much every single month you would just spend just on yourself? [Applause] Whatever we make, we spend. What’s the most you’ve spent for a video? Like anywhere from 300,000 to—Wow! What’s up you guys, it’s Graham here. So if you’ve sp…
Why school leadership and student critical thinking need a desperate do-over | Grant Lichtman
GRANT LICHTMAN: The need that we’ve recognized going back two or three decades at least is rooted in one fundamental issue. The world is rapidly changing around us and the system of education has not. That concept that the world is rapidly changing around…