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
Types of forces and free body diagrams | AP Physics 1 | Khan Academy
In this video, we’re going to discuss different types of forces, but we’re going to do it in the context of free body diagrams. So let’s say that I have a table here, and I have a block that is sitting stationary on that table. What are all of the forces …
Congress is about to make a huge mistake for astronomy #SaveChandra
Congress is about to make a huge mistake in space. In the 1990s, NASA launched four telescopes called the Great Observatories. Their purpose was to study the universe across the electromagnetic spectrum. As the telescopes aged, NASA built replacements for…
A Father at War | The Long Road Home 360
[Music] I’m Sergeant Benjamin Harris, United States Army infantryman. I was 26; my daughter was born two months before we deployed. It’s in those first couple days certain details I can remember very clearly, and then certain things that I would think I r…
All Shower Thoughts I Had This Year
have you ever paused to think about how one of the most famous sentences of all time doesn’t make grammatical sense? Well, because we all apparently heard it wrong and continue to say it wrong. According to the man himself, Neil Armstrong, what he did say…
The Articles of Confederation | Period 3: 1754-1800 | AP US History | Khan Academy
Hey, this is Kim, and I’m here with Leah, KH Academy’s US government and politics fellow. Welcome, Leah! How’s it going? All right, so we’re talking about the Articles of Confederation, which I think many people don’t realize was the first Constitution o…
Dreamcraft (S18) - YC Tech Talks: Gaming 2020 (November 9th, 2020)
Um, so we are Dreamcraft. This is Tian; I’m the founder of Dreamcraft. We went through Y Combinator in the summer 2018 batch. We are building a platform for anybody to create, publish, and monetize games without programming expertise. We believe that the…