Hello there, you beautiful people.
Now, the terminal is a very powerful tool that is designed to allow you to issue what are known as
commands to your computer.
Now, the idea is that the computer will obey these commands, we hope, and make stuff happen as a
result.
Now, in this video, you're going to learn how to issue your first commands, which is very exciting.
But as an aside, this course is structured so that each section of the course has its own cheat sheet
that you can grab at the end of the section.
So don't worry about memorizing all the commands or rushing down to take notes.
Just try it.
The commands that I show you in your own virtual machine or on your own computer, and rest assured
that everything is all jotted down for you in the cheat sheets that you can get at the end of each section.
So that's awesome, right?
So by the end of this video, you will have ran a bunch of Linux commands and you'll start to see a
pattern emerging in how Linux commands work.
So this is going to be a very important lecture.
It's going to give you that foundation.
It's going to help you understand what everything is all about.
So let's go ahead and jump into it.
Okay.
So the first thing we're going to want to do is to open up our terminal.
Now, as a quick challenge, let's see if you can remember how to do that.
Go ahead and see if within about 5 seconds or so you can open up the terminal.
You can do it using either graphical methods or if you're feeling particularly pro already, use the
keyboard shortcut you learned in the last video.
So you've got 5 seconds.
Give it a go.
Did you get it?
Well, if so, well done.
You're learning already.
Now I'm going to open up the terminal using the keyboard shortcut, which is control, alt and T, and
there's the terminal popped up.
Now I'm going to do it like that for most of the time from now on.
So don't be confused.
If you see terminal windows popping up all over the place as we go through the course, I'm just using
the keyboard shortcut, but to make the text a bit easier to read on the recording, I'm just going
to hit view and click zoom in.
We'll make the font just that much larger.
So that should make it a bit easier for you to read when I type stuff.
But now that terminal windows open, let's run a fun command called Echo.
Now the Echo Command just prints out what you give it as an input.
So type with me the following command.
We're going to type Echo, then press space and we're going to type the word hello.
Now when I press enter, I'm going to say to the computer, okay, actually run this command and when
I press enter we see hello, come out of the computer.
It's that's pretty cool.
Let's try that again.
Okay.
We're going to say echo then type echo.
With a load of ohs.
Okay, then I'm going to press enter and what comes back is echo.
How awesome is that?
It's just like a cave.
So let's try now with another command called Cal.
So that's Echo.
Let's try with another command called Cal.
And Cal is going to show up a calendar on the screen.
So if we type Cal just like that and press enter, you can see that we get a calendar for the current
months, for the current month with the with today's date also highlighted.
And now I'm doing this in October 2017.
When you're watching this and doing it yourself, it may be a very different month, but you get the
point.
You type cal.
The default behavior is that you get the current month with the current day highlighted, but that's
just the default behavior of the Cal command.
Now, what makes Linux Command interesting is how you don't have to stick with the default behavior.
You can actually customize the behavior of commands to exactly what you want them to do.
So, for example, what if I wanted the calendar not just for the current month but for the current
year?
But what I could do, first of all, I could type Cal then 2017 and I could press enter and it's going
to give me the entire calendar for 2017 and also it's going to highlight the current date.
So that's pretty cool with very little typing.
We've got a lot more result out of that, right?
But you can also give it something, give each command something called an option.
Now an option is something that allows you to customize the behavior of the command.
So I could type Cal and instead of typing 2017, I could just type dash y.
Now this would give the Cal command the Y option.
Now if I press enter, we also get the calendar for 2017.
So you can see here Cal Dash y gave us the calendar for 2017, again highlighted with the current date.
So you've just seen two ways that you can customize a commands behavior, you can give it input and
you can give it options.
And we're going to be going into a lot more detail about the difference between the two and how they
work.
But you may be curious at the moment as to what other ways you can customize commands, but I'm going
to save that goodness until later at the minute.
I just want to give you a little bit of a bit of an overview of some different commands that you can
use on Linux so you can get comfortable with the typing and pressing enter and seeing results come back
up on the screen.
So let's move on and take a look at another one.
For example, you can see today's date using the date command.
So if we type, date and press enter, we see that we get today's date and time and time zone and year
pop up.
Okay, so that's pretty cool.
It's quite a useful command, but at the moment you can see that we've got quite a lot of text and our
terminal things are starting to get a bit messy.
We can clean that up a bit as well.
So to do that we can use the clear command.
If we type clear and press enter, it's like we just cleaned up our workspace and there we are.
We've removed all the text from the screen now because the clear command is used so often, there's
a key, there's a keyboard shortcut for it.
So if I just type echo and then put blah blah blah, you can see we've got some text come out on the
screen, the computer said blah, blah, blah.
But we can also use a keyboard shortcut to clear the screen.
And that keyboard shortcut is you press control.
And the letter L now we are, we've clear the screen.
Now that's the way that I'm going to be doing it, because it's a lot faster and it's a lot easier than
typing out the clear command every time.
But you feel free.
You do.
You just understand that if the if the terminal is all of a sudden having all its text vanish, that's
what I've done.
I've just cleared the screen now.
We've entered quite a few commands already.
So what if you wanted to enter a command that you've entered previously without having to, you know,
type it out again?
Maybe it was a particularly long command.
We don't know.
But what you can do is you can hit the up arrow key on your keyboard.
So if I press the up arrow key, we see echo, blah, blah, blah, tops, back up.
If I press up again, it's going to go clear.
And again we see date, again we see Cal and so on.
Okay, so you can keep pressing up and cycling backwards through the commands that you've already run,
which is very, very useful.
But you can also look at your whole command history using what's called the history command.
So if you type history and press enter, we can see all of our previous commands with the line number
associated with them.
For example, we can see the line number for our echo command, which is the number one.
Let's say let's there we are.
The line number is number one.
And to run that what you could do instead of having to cycle all the way back up to number one like
that, what I could do is I could type the exclamation mark and then one so exclamation mark on one
and you can see that we've run echo.
Hello.
Okay, so let's, let's have a look again.
Let's have a look at our history again.
We see now let's say we want to run echo, blah, blah, blah.
The line number for that is eight, right?
So if I press the exclamation mark and press eight and then press enter, we see, we get echo, blah,
blah, blah.
So you can see that that's a bit of a shortcut to save you going back through potentially hundreds of
commands that you've run.
And, you know, you can you can run them a bit easier like that.
And if you want to run.
The most recent command that you've done.
You can just press exclamation mark, exclamation mark.
And again, we see blah, blah, blah has run again.
Now this history file can get quite long.
So if you want to clear the history or it's kind of a two step process, you can type history and give
it the C option, then add a semicolon, then type history.
And give it the the W option.
So what that does is it clears the history and then actually writes those changes and makes them permanent.
So when we do that and I've just cleared the screen and we look at history, we can see that all we've
got is just a history command that we literally entered.
So that's something for reference for you.
It's not particularly important, but you've got it in this video if you want to refer back to it.
Okay.
Now, finally, let's say we want to close the terminal.
Okay.
Well, to do that, we could, of course, click the X button at the top right over here.
But you can also type the exit command and make yourself just look that much more pro.
Okay.
So if we press exit, we can see that the terminal has now closed.
And also you could of course use the control DX keyboard shortcuts if I press control and D we can see
that the terminal is also closed as well, like I showed you in the last video.
And that allows you to type commands, operate the terminal and also close it without ever having to
take your hands off the keyboard.
So there you have it.
You've jumped right in and have now ran a whole bunch of Linux commands inside the terminal.
So well done.
You've got your feet wet and we're moving.
As I mentioned to you, you can get a cheat sheet which covers all of the commands that we've covered
in this video and all the other commands that we're going to cover in this section of the course at
the conclusion lecture of this section.
But the use case of these commands that we've covered in this lecture may not be completely clear at
this point, and that's okay.
I wasn't trying to teach you all like a whole bunch of commands in one video.
What I wanted to get across in this video is that commands are executed by typing some weird text in
the terminal and pressing the enter key.
You've also seen that commands can be they can do a whole lot of different things and they can also
be customized for different behavior.
But they all seem to follow a semi similar kind of structure.
You type some text, maybe you've got some options, maybe you've got some input and you press enter.
Now being able to understand that structure is of incredible importance to mastering the Linux operating
system and leveraging the power of the terminal.
So in the next video, I'm going to show you how commands are structured in Linux and what we're going
to cover next will serve as a critical foundation for pretty much everything that we're going to learn
going forward and pretty much everything that you will ever learn when you're using Linux.
If you've used Linux before, but never really felt as though you've, you know, you got it or you
felt that some stuff was missing.
In your understanding, it's probably because you weren't shown what I'm about to show you next.
And if you're new to Linux, this is going to be the best place to start to make sure that everything
goes smoothly and you start to see the pattern of how the Linux operating system and the commands are
designed rather than just memorizing a massive list.
So for that super important stuff, I'll see you in the next video.