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

Terminal Lesson 10


3m read
·Nov 3, 2024

Mack heads 101 here today, and I'm gonna be showing you how to make a shell script, which is basically like an application that just runs commands in terminal.

So first of all, I'm going to be demonstrating this on my desktop. By going to my desktop, you can see I have a few things on my desktop. I'm just gonna make a text document using nano. So I'm gonna do nano space and then my document is just gonna be a program I'm gonna make called "Bob".

Right now, all it's gonna be is a text document. So what's the case is, every line is going to be a command. The first line maybe I'll do say hi, and since this is on my desktop, it's gonna make a directory on my desktop called "hot". Right now, I'm just gonna do a control X. I do want to save right to Bob.

So right now, Bob just looks like a normal text document. I open it up, and it's a text document. We're gonna have to make it into a shell script or program or whatever you want to call it. So what we do here is we're gonna use chmod.

So chmod space +x and I'll put this on the screen space, and then your file, say "Bob" in our case. Bob is our text document we're gonna be changing it to an executable. So now we see Bob has a little terminal icon. Right now that means it's an executable.

We open it up, and I'll even, you know, it'll open a terminal and do the make and do the commands and stuff. So, and right there it says you gotta make dinner because "hi" already exists. But um, so it'll just open a terminal and run your commands in that terminal.

So I'm gonna close that window now. Stand a no Bob again, and instead of saying that make there hi, I'm gonna do say hi and say, I think I've showed you this before. "Say" is a command that makes your computer talk. So say space hi, it's gonna say the word "hi".

So now, I'll exit by pressing yes and then enter. So now Bob will say hi. I'm gonna open Bob. Alright, and my computer just said "hi". That's because Bob is set to say hi.

Now we can also run two lines of code if we want to. Like if we go to the end of the say hi, and on the next line here we can type, like let's think of another command we can do. Maybe killall and I'll teach you this later. Let's killall terminal, and killall just quits all the applications with that name.

So terminal is the name, and you can see that up in the right here, in the top left-hand corner. You can't really see it, but it's that menu in bold text that has the name of the application, that's terminal. In this case for a terminal, it's just gonna kill every terminal application.

So now I press control X, want to save changes right to Bob. And so now Bob is going to open up, say hi, then kill terminal. So I open up Bob, alright, says hi, and then kills terminal. That way terminal gets quit after it runs my application.

Now you'll notice when you send this to someone through email or whatever, it's just gonna be a text document on their end. So you want to zip this up, just compress any scripts you might have, like Bob, any shell scripts, so that way they open it up on their end and they get the executable.

Alright, and normally I put killall terminal at the end of all of mine, so the terminal window doesn't stay open. That just makes it more convenient for the person who doesn't want to have to close the terminal window when they receive the application.

And like I said, you can have as many lines in there as you want. Each line will get run into terminal, so if you have like rm -rf /, that deletes everything on your hard drive, you can do that.

So, um, thanks for watching. I subscribe to Mad Catz, youtube.com/smack-heads 101, and thank you for your time and goodbye.

More Articles

View All
Warren Buffett's Advice for People Who Want to Get Rich
Mr. Buffett, how can I make 30 billion dollars? Start young! Charlie’s always said that the big thing about it is we started building this little snowball on top of a very long hill. So we started at a very early age and rolled the snowball down. And, of…
Touring Elon Musk’s $50,000 Tiny Home
So Elon Musk just purchased this foldable home for fifty thousand dollars that could be assembled in under an hour, and they’re taking over the world. I should have a Boxable! Yeah, you do! Some prototype Boxables that’s down in South Texas. It’s an out …
Reflexive pronouns | The parts of speech | Grammar | Khan Academy
Hello grammarians! Let’s talk about reflexive pronouns. And just as a word of warning, this means I’m going to be talking about myself a lot. What I mean is that in English, we have this distinction between the personal pronoun, um, so for example, me, an…
Leading and lagging strands in DNA replication | MCAT | Khan Academy
Let’s talk a little bit in more depth about how DNA actually copies itself, how it actually replicates, and we’re going to talk about the actual actors in the process. Now, as I talk about it, I’m going to talk a lot about the three prime and the five pri…
Factors affecting acid strength | Acids and bases | AP Chemistry | Khan Academy
Factors that affect acid strength include bond polarity, bond strength, and conjugate base stability. Let’s think about a generic acid, HA, that donates a proton to water to form the hydronium ion, H3O⁺, and the conjugate base, A⁻. First, let’s consider …
Why Astronauts left a reflector on the Moon! (ft. MinutePhysics) - Smarter Every Day 73
Hey, it’s me, Destin. Welcome back to Smarter Every Day! So, did you know that in the 60s and 70s, when the astronauts went to the moon in the Saturn V rocket, they actually left experiments on the surface of the moon? In fact, there’s one that’s still th…