1 00:00:00,084 --> 00:00:03,494 We'll be showing you shell commands all throughout this course, but 2 00:00:03,494 --> 00:00:07,480 this is the only stage that we'll be focused on the shell itself. 3 00:00:07,480 --> 00:00:10,140 Before we wrap this stage up, I wanna show you a few 4 00:00:10,140 --> 00:00:13,050 helpful shortcuts that will make working in the shell easier. 5 00:00:14,190 --> 00:00:15,159 At various points, 6 00:00:15,159 --> 00:00:18,873 you're inevitably going to make typos that prevent a command from working. 7 00:00:18,873 --> 00:00:22,006 It would be a pain to have to type the whole command again just to fix one 8 00:00:22,006 --> 00:00:24,000 missing letter, though. 9 00:00:24,000 --> 00:00:28,280 That's why the shell keeps a list of the commands that you've entered previously. 10 00:00:28,280 --> 00:00:30,580 You can view it with the command history. 11 00:00:31,950 --> 00:00:34,540 You can also press the up arrow on your keyboard to 12 00:00:34,540 --> 00:00:36,515 bring up commands you've run previously. 13 00:00:37,550 --> 00:00:41,550 Pressing the up arrow key takes you back through the list of old commands. 14 00:00:41,550 --> 00:00:45,191 If you go too far, you can press the down arrow key to go forward again. 15 00:00:47,653 --> 00:00:51,816 When you get to the command where you made a typo, you can edit it to fix the issue. 16 00:00:55,547 --> 00:00:58,641 Then just press Enter to run the updated command. 17 00:01:00,342 --> 00:01:03,061 Or if there's a command you want to run again as is, 18 00:01:03,061 --> 00:01:06,050 just hit up arrow to bring it up and press Enter to run it. 19 00:01:07,400 --> 00:01:11,140 By default, your shell may lose all its history when you close the terminal and 20 00:01:11,140 --> 00:01:13,560 it may not save very many old commands. 21 00:01:13,560 --> 00:01:17,510 But it's possible to configure it to save history between terminal sessions and 22 00:01:17,510 --> 00:01:20,210 to save thousands of previous commands. 23 00:01:20,210 --> 00:01:22,820 See the Teacher's Notes for more info. 24 00:01:22,820 --> 00:01:26,770 Another good way to fix typos is to prevent them in the first place. 25 00:01:26,770 --> 00:01:29,290 To do that, you can let your shell do your typing for 26 00:01:29,290 --> 00:01:32,250 you with a feature called tab completion. 27 00:01:32,250 --> 00:01:34,770 You just type the first few letters of a command or 28 00:01:34,770 --> 00:01:36,960 argument, then press the tab key. 29 00:01:36,960 --> 00:01:40,340 The shell will attempt to figure out what you mean and complete the word for you. 30 00:01:41,350 --> 00:01:45,360 Let's say I wanted to run the Who Am I command to get the current user name. 31 00:01:45,360 --> 00:01:50,940 I type the first few letters, W-H-O-A, and press the tab key on my keyboard. 32 00:01:51,990 --> 00:01:56,310 The Who Am I command is the only one that starts with W-H-O-A, so 33 00:01:56,310 --> 00:01:59,870 the shell realizes that's what I must be trying to run. 34 00:01:59,870 --> 00:02:04,410 It types the remaining letters of the command name for me, followed by a space. 35 00:02:04,410 --> 00:02:07,170 Now I can just press Enter to run the command. 36 00:02:07,170 --> 00:02:09,770 I can do the same with the history command. 37 00:02:09,770 --> 00:02:13,970 I type the first three letters, H-I-S, and press tab. 38 00:02:13,970 --> 00:02:15,790 The shell completes the command name for me, 39 00:02:15,790 --> 00:02:18,140 and all I have to do is press Enter to run it. 40 00:02:19,230 --> 00:02:22,750 Tab completion works with file name arguments too. 41 00:02:22,750 --> 00:02:25,450 Let me change to the parent directory here, 42 00:02:25,450 --> 00:02:27,780 we'll cover how this command works in a later video. 43 00:02:29,670 --> 00:02:35,130 Now, suppose I want to pass the statue.txt and bird.txt files to the cat command. 44 00:02:35,130 --> 00:02:37,553 I type cat, followed by a space, 45 00:02:37,553 --> 00:02:44,270 then I type the first few letters of the first file name, stat, and press tab. 46 00:02:44,270 --> 00:02:48,909 The shell realizes that there's only one file here that starts with stat, and 47 00:02:48,909 --> 00:02:52,320 so it completes the rest of the file name, statue.txt. 48 00:02:52,320 --> 00:02:56,728 I also want bird.txt, so I type the first few letters of its name, 49 00:02:56,728 --> 00:02:59,180 B-I-R, and press tab. 50 00:02:59,180 --> 00:03:02,770 Again, the shell realizes that I must mean the bird.txt file and 51 00:03:02,770 --> 00:03:04,960 completes the file name for me. 52 00:03:04,960 --> 00:03:06,990 Now I can press Enter to run the command, and 53 00:03:06,990 --> 00:03:09,610 cat will print out the contents of the two text files. 54 00:03:10,720 --> 00:03:12,890 That's the magic of tab completion. 55 00:03:12,890 --> 00:03:16,730 The shell isn't actually reading your mind, but sometimes it seems like it is. 56 00:03:17,970 --> 00:03:22,050 By the way, even though tab completion originated in command line shells, 57 00:03:22,050 --> 00:03:26,750 it's starting to show up in places like browser address bars and email clients. 58 00:03:26,750 --> 00:03:30,890 So once you learn to use tab completion, it will help you outside the terminal too. 59 00:03:31,950 --> 00:03:35,870 So now you know the basics of using the shell and the command line. 60 00:03:35,870 --> 00:03:39,240 In the next stage, we're going to show you more about working with directories and 61 00:03:39,240 --> 00:03:39,960 files. 62 00:03:39,960 --> 00:03:40,480 See you there.