1 00:00:00,300 --> 00:00:01,880 Hello there, you beautiful people. 2 00:00:01,890 --> 00:00:06,540 Now, the terminal is a very powerful tool that is designed to allow you to issue what are known as 3 00:00:06,540 --> 00:00:08,470 commands to your computer. 4 00:00:08,490 --> 00:00:13,770 Now, the idea is that the computer will obey these commands, we hope, and make stuff happen as a 5 00:00:13,770 --> 00:00:14,340 result. 6 00:00:14,340 --> 00:00:19,770 Now, in this video, you're going to learn how to issue your first commands, which is very exciting. 7 00:00:19,770 --> 00:00:24,720 But as an aside, this course is structured so that each section of the course has its own cheat sheet 8 00:00:24,720 --> 00:00:26,610 that you can grab at the end of the section. 9 00:00:26,610 --> 00:00:30,270 So don't worry about memorizing all the commands or rushing down to take notes. 10 00:00:30,270 --> 00:00:30,900 Just try it. 11 00:00:30,900 --> 00:00:35,160 The commands that I show you in your own virtual machine or on your own computer, and rest assured 12 00:00:35,160 --> 00:00:40,260 that everything is all jotted down for you in the cheat sheets that you can get at the end of each section. 13 00:00:40,260 --> 00:00:41,340 So that's awesome, right? 14 00:00:41,760 --> 00:00:46,650 So by the end of this video, you will have ran a bunch of Linux commands and you'll start to see a 15 00:00:46,650 --> 00:00:49,680 pattern emerging in how Linux commands work. 16 00:00:49,680 --> 00:00:51,750 So this is going to be a very important lecture. 17 00:00:51,750 --> 00:00:52,860 It's going to give you that foundation. 18 00:00:52,860 --> 00:00:55,710 It's going to help you understand what everything is all about. 19 00:00:55,710 --> 00:00:58,170 So let's go ahead and jump into it. 20 00:01:00,440 --> 00:01:00,830 Okay. 21 00:01:00,830 --> 00:01:04,040 So the first thing we're going to want to do is to open up our terminal. 22 00:01:04,040 --> 00:01:07,160 Now, as a quick challenge, let's see if you can remember how to do that. 23 00:01:07,190 --> 00:01:11,150 Go ahead and see if within about 5 seconds or so you can open up the terminal. 24 00:01:11,150 --> 00:01:15,710 You can do it using either graphical methods or if you're feeling particularly pro already, use the 25 00:01:15,710 --> 00:01:17,780 keyboard shortcut you learned in the last video. 26 00:01:17,780 --> 00:01:19,130 So you've got 5 seconds. 27 00:01:19,130 --> 00:01:20,000 Give it a go. 28 00:01:26,130 --> 00:01:26,970 Did you get it? 29 00:01:27,000 --> 00:01:28,420 Well, if so, well done. 30 00:01:28,440 --> 00:01:29,650 You're learning already. 31 00:01:29,670 --> 00:01:35,580 Now I'm going to open up the terminal using the keyboard shortcut, which is control, alt and T, and 32 00:01:36,000 --> 00:01:37,580 there's the terminal popped up. 33 00:01:37,590 --> 00:01:40,260 Now I'm going to do it like that for most of the time from now on. 34 00:01:40,260 --> 00:01:41,190 So don't be confused. 35 00:01:41,190 --> 00:01:45,570 If you see terminal windows popping up all over the place as we go through the course, I'm just using 36 00:01:45,570 --> 00:01:49,440 the keyboard shortcut, but to make the text a bit easier to read on the recording, I'm just going 37 00:01:49,440 --> 00:01:51,300 to hit view and click zoom in. 38 00:01:51,300 --> 00:01:53,580 We'll make the font just that much larger. 39 00:01:53,970 --> 00:01:56,790 So that should make it a bit easier for you to read when I type stuff. 40 00:01:57,450 --> 00:02:01,740 But now that terminal windows open, let's run a fun command called Echo. 41 00:02:01,740 --> 00:02:05,460 Now the Echo Command just prints out what you give it as an input. 42 00:02:05,460 --> 00:02:07,710 So type with me the following command. 43 00:02:07,710 --> 00:02:13,560 We're going to type Echo, then press space and we're going to type the word hello. 44 00:02:14,130 --> 00:02:19,170 Now when I press enter, I'm going to say to the computer, okay, actually run this command and when 45 00:02:19,170 --> 00:02:22,510 I press enter we see hello, come out of the computer. 46 00:02:22,530 --> 00:02:23,520 It's that's pretty cool. 47 00:02:23,550 --> 00:02:24,450 Let's try that again. 48 00:02:24,450 --> 00:02:24,740 Okay. 49 00:02:24,780 --> 00:02:27,750 We're going to say echo then type echo. 50 00:02:28,940 --> 00:02:30,030 With a load of ohs. 51 00:02:30,060 --> 00:02:34,820 Okay, then I'm going to press enter and what comes back is echo. 52 00:02:35,120 --> 00:02:35,860 How awesome is that? 53 00:02:35,870 --> 00:02:36,950 It's just like a cave. 54 00:02:36,980 --> 00:02:40,350 So let's try now with another command called Cal. 55 00:02:40,370 --> 00:02:41,360 So that's Echo. 56 00:02:41,390 --> 00:02:42,890 Let's try with another command called Cal. 57 00:02:42,890 --> 00:02:46,280 And Cal is going to show up a calendar on the screen. 58 00:02:46,400 --> 00:02:53,120 So if we type Cal just like that and press enter, you can see that we get a calendar for the current 59 00:02:53,120 --> 00:02:58,370 months, for the current month with the with today's date also highlighted. 60 00:02:58,370 --> 00:03:00,740 And now I'm doing this in October 2017. 61 00:03:00,740 --> 00:03:04,490 When you're watching this and doing it yourself, it may be a very different month, but you get the 62 00:03:04,490 --> 00:03:04,760 point. 63 00:03:04,760 --> 00:03:05,480 You type cal. 64 00:03:05,480 --> 00:03:11,450 The default behavior is that you get the current month with the current day highlighted, but that's 65 00:03:11,450 --> 00:03:14,180 just the default behavior of the Cal command. 66 00:03:14,450 --> 00:03:18,950 Now, what makes Linux Command interesting is how you don't have to stick with the default behavior. 67 00:03:18,950 --> 00:03:22,900 You can actually customize the behavior of commands to exactly what you want them to do. 68 00:03:22,910 --> 00:03:27,140 So, for example, what if I wanted the calendar not just for the current month but for the current 69 00:03:27,140 --> 00:03:27,950 year? 70 00:03:27,980 --> 00:03:34,850 But what I could do, first of all, I could type Cal then 2017 and I could press enter and it's going 71 00:03:34,850 --> 00:03:40,930 to give me the entire calendar for 2017 and also it's going to highlight the current date. 72 00:03:40,940 --> 00:03:43,250 So that's pretty cool with very little typing. 73 00:03:43,250 --> 00:03:45,560 We've got a lot more result out of that, right? 74 00:03:45,590 --> 00:03:50,870 But you can also give it something, give each command something called an option. 75 00:03:51,440 --> 00:03:55,520 Now an option is something that allows you to customize the behavior of the command. 76 00:03:55,790 --> 00:04:01,400 So I could type Cal and instead of typing 2017, I could just type dash y. 77 00:04:01,400 --> 00:04:04,430 Now this would give the Cal command the Y option. 78 00:04:04,430 --> 00:04:09,830 Now if I press enter, we also get the calendar for 2017. 79 00:04:09,830 --> 00:04:15,290 So you can see here Cal Dash y gave us the calendar for 2017, again highlighted with the current date. 80 00:04:15,290 --> 00:04:20,149 So you've just seen two ways that you can customize a commands behavior, you can give it input and 81 00:04:20,149 --> 00:04:21,410 you can give it options. 82 00:04:21,410 --> 00:04:25,490 And we're going to be going into a lot more detail about the difference between the two and how they 83 00:04:25,490 --> 00:04:25,910 work. 84 00:04:25,910 --> 00:04:31,040 But you may be curious at the moment as to what other ways you can customize commands, but I'm going 85 00:04:31,040 --> 00:04:32,960 to save that goodness until later at the minute. 86 00:04:32,960 --> 00:04:37,910 I just want to give you a little bit of a bit of an overview of some different commands that you can 87 00:04:37,910 --> 00:04:42,650 use on Linux so you can get comfortable with the typing and pressing enter and seeing results come back 88 00:04:42,650 --> 00:04:43,370 up on the screen. 89 00:04:43,790 --> 00:04:46,280 So let's move on and take a look at another one. 90 00:04:47,240 --> 00:04:50,540 For example, you can see today's date using the date command. 91 00:04:50,540 --> 00:04:57,920 So if we type, date and press enter, we see that we get today's date and time and time zone and year 92 00:04:57,920 --> 00:04:58,490 pop up. 93 00:04:58,490 --> 00:04:59,480 Okay, so that's pretty cool. 94 00:04:59,480 --> 00:05:04,220 It's quite a useful command, but at the moment you can see that we've got quite a lot of text and our 95 00:05:04,220 --> 00:05:06,320 terminal things are starting to get a bit messy. 96 00:05:06,320 --> 00:05:07,910 We can clean that up a bit as well. 97 00:05:07,910 --> 00:05:10,220 So to do that we can use the clear command. 98 00:05:10,220 --> 00:05:16,130 If we type clear and press enter, it's like we just cleaned up our workspace and there we are. 99 00:05:16,130 --> 00:05:20,990 We've removed all the text from the screen now because the clear command is used so often, there's 100 00:05:20,990 --> 00:05:23,000 a key, there's a keyboard shortcut for it. 101 00:05:23,420 --> 00:05:29,270 So if I just type echo and then put blah blah blah, you can see we've got some text come out on the 102 00:05:29,270 --> 00:05:31,130 screen, the computer said blah, blah, blah. 103 00:05:31,220 --> 00:05:34,340 But we can also use a keyboard shortcut to clear the screen. 104 00:05:34,340 --> 00:05:36,770 And that keyboard shortcut is you press control. 105 00:05:36,770 --> 00:05:39,630 And the letter L now we are, we've clear the screen. 106 00:05:39,630 --> 00:05:42,620 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 107 00:05:42,620 --> 00:05:44,360 typing out the clear command every time. 108 00:05:44,360 --> 00:05:45,290 But you feel free. 109 00:05:45,290 --> 00:05:45,620 You do. 110 00:05:45,650 --> 00:05:51,950 You just understand that if the if the terminal is all of a sudden having all its text vanish, that's 111 00:05:51,950 --> 00:05:52,370 what I've done. 112 00:05:52,370 --> 00:05:54,740 I've just cleared the screen now. 113 00:05:54,740 --> 00:05:56,600 We've entered quite a few commands already. 114 00:05:56,600 --> 00:06:01,340 So what if you wanted to enter a command that you've entered previously without having to, you know, 115 00:06:01,430 --> 00:06:02,210 type it out again? 116 00:06:02,210 --> 00:06:03,680 Maybe it was a particularly long command. 117 00:06:03,680 --> 00:06:04,340 We don't know. 118 00:06:04,340 --> 00:06:08,060 But what you can do is you can hit the up arrow key on your keyboard. 119 00:06:08,060 --> 00:06:11,990 So if I press the up arrow key, we see echo, blah, blah, blah, tops, back up. 120 00:06:11,990 --> 00:06:14,090 If I press up again, it's going to go clear. 121 00:06:14,090 --> 00:06:16,820 And again we see date, again we see Cal and so on. 122 00:06:16,820 --> 00:06:22,460 Okay, so you can keep pressing up and cycling backwards through the commands that you've already run, 123 00:06:22,460 --> 00:06:23,960 which is very, very useful. 124 00:06:24,740 --> 00:06:29,540 But you can also look at your whole command history using what's called the history command. 125 00:06:29,540 --> 00:06:35,780 So if you type history and press enter, we can see all of our previous commands with the line number 126 00:06:35,780 --> 00:06:36,890 associated with them. 127 00:06:36,890 --> 00:06:41,630 For example, we can see the line number for our echo command, which is the number one. 128 00:06:41,630 --> 00:06:44,630 Let's say let's there we are. 129 00:06:44,630 --> 00:06:45,710 The line number is number one. 130 00:06:45,710 --> 00:06:50,990 And to run that what you could do instead of having to cycle all the way back up to number one like 131 00:06:50,990 --> 00:06:58,130 that, what I could do is I could type the exclamation mark and then one so exclamation mark on one 132 00:06:58,130 --> 00:06:59,990 and you can see that we've run echo. 133 00:06:59,990 --> 00:07:00,650 Hello. 134 00:07:00,680 --> 00:07:02,360 Okay, so let's, let's have a look again. 135 00:07:02,360 --> 00:07:03,710 Let's have a look at our history again. 136 00:07:03,800 --> 00:07:07,010 We see now let's say we want to run echo, blah, blah, blah. 137 00:07:07,100 --> 00:07:09,230 The line number for that is eight, right? 138 00:07:09,230 --> 00:07:15,140 So if I press the exclamation mark and press eight and then press enter, we see, we get echo, blah, 139 00:07:15,140 --> 00:07:15,620 blah, blah. 140 00:07:15,620 --> 00:07:20,870 So you can see that that's a bit of a shortcut to save you going back through potentially hundreds of 141 00:07:20,870 --> 00:07:21,710 commands that you've run. 142 00:07:21,710 --> 00:07:25,580 And, you know, you can you can run them a bit easier like that. 143 00:07:27,260 --> 00:07:28,010 And if you want to run. 144 00:07:28,080 --> 00:07:29,760 The most recent command that you've done. 145 00:07:29,760 --> 00:07:32,400 You can just press exclamation mark, exclamation mark. 146 00:07:32,730 --> 00:07:35,490 And again, we see blah, blah, blah has run again. 147 00:07:36,420 --> 00:07:38,730 Now this history file can get quite long. 148 00:07:38,730 --> 00:07:46,020 So if you want to clear the history or it's kind of a two step process, you can type history and give 149 00:07:46,020 --> 00:07:50,880 it the C option, then add a semicolon, then type history. 150 00:07:52,590 --> 00:07:55,140 And give it the the W option. 151 00:07:55,380 --> 00:07:59,580 So what that does is it clears the history and then actually writes those changes and makes them permanent. 152 00:07:59,580 --> 00:08:04,770 So when we do that and I've just cleared the screen and we look at history, we can see that all we've 153 00:08:04,770 --> 00:08:06,600 got is just a history command that we literally entered. 154 00:08:06,600 --> 00:08:08,010 So that's something for reference for you. 155 00:08:08,010 --> 00:08:11,910 It's not particularly important, but you've got it in this video if you want to refer back to it. 156 00:08:11,940 --> 00:08:12,370 Okay. 157 00:08:12,660 --> 00:08:16,320 Now, finally, let's say we want to close the terminal. 158 00:08:16,350 --> 00:08:16,640 Okay. 159 00:08:16,710 --> 00:08:20,370 Well, to do that, we could, of course, click the X button at the top right over here. 160 00:08:20,370 --> 00:08:25,100 But you can also type the exit command and make yourself just look that much more pro. 161 00:08:25,110 --> 00:08:25,310 Okay. 162 00:08:25,380 --> 00:08:30,060 So if we press exit, we can see that the terminal has now closed. 163 00:08:30,060 --> 00:08:37,169 And also you could of course use the control DX keyboard shortcuts if I press control and D we can see 164 00:08:37,169 --> 00:08:40,110 that the terminal is also closed as well, like I showed you in the last video. 165 00:08:40,110 --> 00:08:44,580 And that allows you to type commands, operate the terminal and also close it without ever having to 166 00:08:44,580 --> 00:08:46,530 take your hands off the keyboard. 167 00:08:48,070 --> 00:08:48,910 So there you have it. 168 00:08:48,910 --> 00:08:52,900 You've jumped right in and have now ran a whole bunch of Linux commands inside the terminal. 169 00:08:52,900 --> 00:08:53,730 So well done. 170 00:08:53,740 --> 00:08:55,630 You've got your feet wet and we're moving. 171 00:08:55,660 --> 00:08:59,590 As I mentioned to you, you can get a cheat sheet which covers all of the commands that we've covered 172 00:08:59,590 --> 00:09:04,240 in this video and all the other commands that we're going to cover in this section of the course at 173 00:09:04,240 --> 00:09:07,090 the conclusion lecture of this section. 174 00:09:07,090 --> 00:09:11,560 But the use case of these commands that we've covered in this lecture may not be completely clear at 175 00:09:11,560 --> 00:09:13,120 this point, and that's okay. 176 00:09:13,150 --> 00:09:16,870 I wasn't trying to teach you all like a whole bunch of commands in one video. 177 00:09:16,870 --> 00:09:21,460 What I wanted to get across in this video is that commands are executed by typing some weird text in 178 00:09:21,460 --> 00:09:23,680 the terminal and pressing the enter key. 179 00:09:23,710 --> 00:09:28,180 You've also seen that commands can be they can do a whole lot of different things and they can also 180 00:09:28,180 --> 00:09:30,250 be customized for different behavior. 181 00:09:30,250 --> 00:09:34,390 But they all seem to follow a semi similar kind of structure. 182 00:09:34,600 --> 00:09:38,230 You type some text, maybe you've got some options, maybe you've got some input and you press enter. 183 00:09:38,260 --> 00:09:44,020 Now being able to understand that structure is of incredible importance to mastering the Linux operating 184 00:09:44,020 --> 00:09:46,390 system and leveraging the power of the terminal. 185 00:09:46,390 --> 00:09:51,250 So in the next video, I'm going to show you how commands are structured in Linux and what we're going 186 00:09:51,250 --> 00:09:56,200 to cover next will serve as a critical foundation for pretty much everything that we're going to learn 187 00:09:56,200 --> 00:10:00,310 going forward and pretty much everything that you will ever learn when you're using Linux. 188 00:10:00,310 --> 00:10:05,530 If you've used Linux before, but never really felt as though you've, you know, you got it or you 189 00:10:05,530 --> 00:10:07,150 felt that some stuff was missing. 190 00:10:07,150 --> 00:10:11,350 In your understanding, it's probably because you weren't shown what I'm about to show you next. 191 00:10:11,350 --> 00:10:15,970 And if you're new to Linux, this is going to be the best place to start to make sure that everything 192 00:10:15,970 --> 00:10:19,870 goes smoothly and you start to see the pattern of how the Linux operating system and the commands are 193 00:10:19,870 --> 00:10:22,810 designed rather than just memorizing a massive list. 194 00:10:22,810 --> 00:10:26,380 So for that super important stuff, I'll see you in the next video.