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

Terminal Lesson 2


4m read
·Nov 3, 2024

Mad Kids 101 here!

Today we're gonna show you another few simple terminal tricks. The commands I'm going to be teaching you today allow you to write a text document. They allow you to switch users and substitute a user.

So first of all, let's teach you how to make a text document and how to edit a text document. First of all, I'm going to be demonstrating this on my desktop, so I'm going to do cd desktop right here. Now I can see what's on my desktop, and you'll notice that it's accurately correct once again. There's my desktop.

So let's type the command nano, which is actually a word processor, space, and then a new file name. If it has spaces, we do the file name in quotes. So, "dave was here". Now, inside of this, we can use the arrow keys to move around, and we just type random stuff.

“dave was here.” And now, you'll notice at the bottom there are some key strokes which you'll see. There is a little arrow before the letter that means control. So x in this case is Control + X. We're gonna type Control + X to exit Nano, and when we do that, it'll ask us if we want to save changes. Press y for yes and n for no and Control + C to cancel. In this case, we do want to save changes, and click y for yes.

Now we just hit enter. Here it's asking us what the file name is, so we type "dave was here" and hit enter. Now you can see on my desktop there's a file called "dave was here." Now we can open that up, and that's what we typed.

So, that "dave is here." Another thing we can do is, we can nano a file that already exists like "hi bob" that is right now on my desktop. That was from another thing. So we're going to type nano space and quotes "hi bob".

Now we hit enter. "hi bob." I'm just anyway, we can move around the arrow keys and do... can and let's just type stuff. Control + X to exit. No, we don't want to save.

And so we can open it up, and that's definitely what it says. We can do a cat of our files like cat dave was here instead of nano dave was here to just read a file, and it's correct right there. It says “dave is here.”

So now, what I'm gonna be showing you is how to switch users. Now, in order to switch users, you type su space and then a username. So, to switch users to Alex, I'd type su space Alex. Then the password for Alex.

Now I'm logged in as Alex, and I can type who am I, and it shows me my username right there. Can type pwd and I’m in Alex's home directory on the desk. I can type exit to log out as that user and go back to the last user.

So now, I can type sudo, which is another command. It means Substitute User Do space who am I, and that's going to ask me for my password for the current user that ran sudo. I typed that, and then it says "worked". Even though I'm logged in as Alex right now, I can just take who am I, and I'm Alex.

So what sudo does by default is it runs a command as root. Now, if we want to, you can also make sudo run a command as some other user. So we can type sudo -u and then space "guest", and I run the command as guest. who am I. Like I might have told you, this just displays your username, so that's very useful.

Now another thing, which I've already been doing, is the up and down arrows go through past commands. Down goes to the next command, and up goes to the previous command. history will display all the commands that you've ever done, like right here, and it numbers them.

history -c...well, I don’t want to do that because I have some stuff which I want to keep in my history. So, now what we're gonna do is, I've showed you how to do that.

Another thing I’ll just explain real quickly—and you don't really have to listen to this—is the file system, and I’ll actually have a separate video on this.

So you'll notice that to see all the users, you do ls /users. That's because all the users' home directories are in /users. So every user on the computer, that's an actual user, not the guest user, has a little folder in /users that has all their stuff.

So if you just type su with no username and then type the root password, which in my case is long, then you can type ls /users and then you can do /Alex, and then you can read what's on my desktop without having to be logged in as me, 'cause root has ultimate permissions.

You can also use sudo su root, which is “su do,” and that runs the command as the root user. What sudo does, you know, like I said, is it runs a command by default as root, and root can su to any user without the password.

So if we run su root as root, then it will log us in as root without needing a password. So if you haven't set a root password, it'll log you in as the root user. sudo su root, and you might have to type your password before you do sudo because that's standard sudo.

But now I can type who am I, and I'm going, and I can type exit to log out. So, and yeah, so that's basically everything I have to show you for today.

If you have any questions, leave a comment in the comment box. For more terminal lessons, because this is actually terminal lesson two, go to Mac Heads 101 on YouTube. So it's youtube.com/macheads101 to see more information about computers. We have a lot of videos.

So, thanks for stopping by. Goodbye!

More Articles

View All
Human Cow BREAST MILK??? -- Mind Blow #18
A vending machine toy capsule wall and Charlie Sheen mask. Vsauce, Kevin here. This is Mind Blow. You know Mario Kart’s Rainbow Road? Well, here’s the rainbow walkway. It’s a 52 metre panorama located on the roof of a building in Denmark, and visitors ca…
Biden's Student Loan Forgiveness Is A MISTAKE! | Sen. Lummis Crypto Policy Interview
[Applause] [Music] The Biden administration is leaning towards ten thousand dollars in student loan forgiveness. For more on this issue and a look at the best path forward, let’s bring in O’Leary Ventures chairman Kevin O’Leary. He’s also a CNBC contribut…
Representing quantities with vectors | Vectors | Precalculus | Khan Academy
We’re told a powerful magnet is attracting a metal ball on a flat surface. The magnet is pulling the ball at a force of 15 newtons, and the magnet is 20 degrees to the south from the eastward direction relative to the ball. Here are a few vectors where th…
Car Trouble - Deleted Scene | Life Below Zero
[Music] Hooked up my generator to my truck. Trucks don’t like to start in these kind of temperatures, so you got to have a way of warming them up. What mine has is an electrical outlet that heats the block heater, the oil pan, and the battery in it to wa…
How to read a document | The historian's toolkit | US History | Khan Academy
Hello David, hello Kim. So today what we’re doing is taking a look at this speech by one of my favorite Presidents, Franklin Delano Roosevelt, which he gave at his inauguration in 1933. I think what’s really important about looking at a speech like this i…
Wave properties | Wave properties | High School Physics | Khan Academy
Imagine that I’m standing here holding the end of a rope. I’m over here on the left end, and while holding the rope, I rapidly move my hand up, down, and back to the starting position. If we were to take a snapshot of the rope immediately after I finish m…