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
$1 Million to $100 Million in sales as a Real Estate Agent
My personal philosophy is that every listing you have should give you at least one more listing from it and one buyer from it. So hopefully, one listing leads to two more sales, which should lead to two more sales, and it just branches out from there. Wh…
How To Do This ‘Stoic’ Thing? | Books
How can we apply Stoicism in our daily lives? This is what a book, Practical Stoicism: Exercises for Doing the Right Thing Right Now, is all about. Robbing Homer offered me the opportunity to listen to the Audible version of this book, which he narrated, …
What Happens To You If You Never Go Outside?
You’ve heard your whole life that going outside is good for you, but is it really? I mean, don’t get me wrong; there are some definite healthy effects to going outside. Like when you’re exposed to direct sunlight, you get some vitamin D, and if you do exe…
The power of 'yet' with Zoe and Elmo from Sesame Street
Okay, you’re almost ready. Oh wait, I’m almost ready. Okay, um, there you go. Okay, ready? And the zombie mobile! Three, two, one… oh! One baby boy! I almost want to work. Mine didn’t work. I, I need a do-over. All right, three, two, one… it didn’t work …
Analyzing functions for discontinuities (continuous example) | AP Calculus AB | Khan Academy
So we have ( g(x) ) being defined as the log of ( 3x ) when ( 0 < x < 3 ) and ( 4 - x ) times the log of ( 9 ) when ( x \geq 3 ). So based on this definition of ( g(x) ), we want to find the limit of ( g(x) ) as ( x ) approaches ( 3 ). Once again, …
Recursive formulas for arithmetic sequences | Mathematics I | High School Math | Khan Academy
G is a function that describes an arithmetic sequence. Here are the first few terms of the sequence: the first term is four, the second term is three and four-fifths, the third term is three and three-fifths, and the fourth term is three and two-fifths. …