1 00:00:00,084 --> 00:00:02,470 The terminal is a text interface. 2 00:00:02,470 --> 00:00:05,870 By default, terminals run a program called a shell. 3 00:00:05,870 --> 00:00:08,130 There are many different shell programs available, 4 00:00:08,130 --> 00:00:13,870 most of them with names ending in SH, like ZSH, KSH, and so on. 5 00:00:13,870 --> 00:00:17,310 Most operating systems today run a shell called Bash, and 6 00:00:17,310 --> 00:00:19,330 that's what we're running here. 7 00:00:19,330 --> 00:00:21,910 All the different shells work very similarly, so 8 00:00:21,910 --> 00:00:25,450 the things you'll learn in Bash will be applicable in the other shells too. 9 00:00:26,570 --> 00:00:30,450 You can see a bunch of text here, ending in a dollar sign. 10 00:00:30,450 --> 00:00:35,040 This is the shell prompt, the shell is prompting you to type something. 11 00:00:35,040 --> 00:00:38,800 Most shell prompts end with a dollar sign, like this. 12 00:00:38,800 --> 00:00:42,300 The blinking box following the dollar sign is the cursor, 13 00:00:42,300 --> 00:00:44,870 it's the place the text you type will appear. 14 00:00:44,870 --> 00:00:49,070 It mostly works like the cursors you've seen in word processors and web forms, but 15 00:00:49,070 --> 00:00:51,030 with a few exceptions. 16 00:00:51,030 --> 00:00:53,702 You can type text with the letter keys on your keyboard, and 17 00:00:53,702 --> 00:00:56,557 you can delete it with the backspace key. 18 00:00:56,557 --> 00:00:57,650 You can move back and 19 00:00:57,650 --> 00:01:02,100 forth within the text you've typed on this line with the left and right arrow keys. 20 00:01:02,100 --> 00:01:06,270 But you can only type on this one line, you can't move off of it. 21 00:01:06,270 --> 00:01:07,250 If you press the up and 22 00:01:07,250 --> 00:01:11,830 down arrow keys, it will instead cycle through entries you've made previously. 23 00:01:11,830 --> 00:01:14,900 Here you can see it bringing up commands I entered before. 24 00:01:14,900 --> 00:01:18,680 This is called command history, and we'll talk about it more in an upcoming video. 25 00:01:19,950 --> 00:01:23,645 If I hit the Enter key without typing anything, it won't really do anything, 26 00:01:23,645 --> 00:01:25,340 it'll just display another prompt. 27 00:01:26,640 --> 00:01:31,401 We can run commands at the prompt to execute other programs inside the shell. 28 00:01:31,401 --> 00:01:34,890 The output of these commands will be shown in the terminal. 29 00:01:34,890 --> 00:01:38,720 Because the shell offers you a single line of text where you enter commands, 30 00:01:38,720 --> 00:01:41,200 this is often referred to as the command line. 31 00:01:42,300 --> 00:01:46,950 Let's try running a program called ls, which is used for listing files. 32 00:01:46,950 --> 00:01:49,820 I type ls and press the Enter key to run the command. 33 00:01:50,830 --> 00:01:55,660 The program runs, and its output appears on the terminal below the command line. 34 00:01:55,660 --> 00:01:59,110 The program prints out the names of several files. 35 00:01:59,110 --> 00:02:03,130 Then the ls program finishes, and we're returned to our shell prompt. 36 00:02:03,130 --> 00:02:05,380 The shell is ready for us to type another command. 37 00:02:06,480 --> 00:02:08,310 Let's try running another program. 38 00:02:08,310 --> 00:02:10,390 This time we'll run the whoami command, 39 00:02:10,390 --> 00:02:12,440 which prints the name of the current user account. 40 00:02:13,640 --> 00:02:16,610 It looks like we're logged in as a user named treehouse. 41 00:02:17,640 --> 00:02:20,830 Once again, the program completes and we're returned to the shell prompt. 42 00:02:21,890 --> 00:02:25,190 Now I'll run a program called cat, which concatenates or 43 00:02:25,190 --> 00:02:27,200 joins the contents of files together. 44 00:02:28,760 --> 00:02:32,330 Normally, you'd provide the names of one or more files you want cat to print out. 45 00:02:32,330 --> 00:02:36,230 But since I didn't provide any, the cat program sits there waiting for input. 46 00:02:38,090 --> 00:02:41,770 I don't want to use this right now, so I'm going to stop the cat program. 47 00:02:41,770 --> 00:02:46,520 To do this, I hold down the Ctrl key on my keyboard and press the C key. 48 00:02:46,520 --> 00:02:50,580 This special key combination sends a signal to the program telling it that I 49 00:02:50,580 --> 00:02:51,170 want to quit. 50 00:02:52,500 --> 00:02:55,070 Any time a terminal program appears to be stuck or 51 00:02:55,070 --> 00:03:00,020 isn't doing what you want, you can press Ctrl+C to send it this signal. 52 00:03:00,020 --> 00:03:03,470 Most of the time, the program will quit and return you to the shell prompt, so 53 00:03:03,470 --> 00:03:05,530 you can run another command. 54 00:03:05,530 --> 00:03:08,250 By the way, you may be wondering what's up with these crazy command 55 00:03:08,250 --> 00:03:10,550 names like ls and cat. 56 00:03:10,550 --> 00:03:11,950 When you're working in the terminal, 57 00:03:11,950 --> 00:03:14,040 there are certain commands you'll be using a lot. 58 00:03:15,040 --> 00:03:17,820 You don't wanna have to type the word list over and over, so 59 00:03:17,820 --> 00:03:20,800 the command name is abbreviated to ls. 60 00:03:20,800 --> 00:03:22,970 You don't wanna type concatenated all the time, so 61 00:03:22,970 --> 00:03:25,080 the name is shortened to cat, and so on. 62 00:03:26,230 --> 00:03:29,830 The abbreviations take a little extra time when you're learning the commands. 63 00:03:29,830 --> 00:03:33,350 But believe me, they'll save you some typing in the long run. 64 00:03:33,350 --> 00:03:35,300 Let me run one more program, clear. 65 00:03:36,870 --> 00:03:39,930 The clear program clears output from the terminal screen, 66 00:03:39,930 --> 00:03:42,020 moving the prompt up to the top. 67 00:03:42,020 --> 00:03:45,280 By default, Bash shell also supports a keyboard shortcut that 68 00:03:45,280 --> 00:03:48,930 does the same thing, just hold the Ctrl key and press L. 69 00:03:50,240 --> 00:03:52,750 You don't have to remember this key combination, 70 00:03:52,750 --> 00:03:55,300 it's not as important as Ctrl+C. 71 00:03:55,300 --> 00:03:57,690 But if you see me clear the screen during this course, 72 00:03:57,690 --> 00:04:00,930 you'll know I did it by pressing Ctrl+L. 73 00:04:00,930 --> 00:04:04,120 Before we move on, I should point out a couple more aspects of the prompt. 74 00:04:05,260 --> 00:04:08,488 This prompt shows the name of the current user, treehouse. 75 00:04:10,627 --> 00:04:16,690 Then it shows the directory or folder that we're in, ~/workspace, or just workspace. 76 00:04:17,780 --> 00:04:19,880 I can change to a different directory, and 77 00:04:19,880 --> 00:04:23,640 the directory name will be updated when the new prompt is shown. 78 00:04:23,640 --> 00:04:27,540 We'll talk more about directories and the cd command later. 79 00:04:27,540 --> 00:04:28,610 As I mentioned before, 80 00:04:28,610 --> 00:04:32,450 the end of the prompt is usually marked with a dollar sign for normal users. 81 00:04:32,450 --> 00:04:36,390 This could be changed, but it's conventional to use a dollar sign. 82 00:04:36,390 --> 00:04:37,860 The prompt is customizable, so 83 00:04:37,860 --> 00:04:41,070 don't worry too much if the prompt on your system shows different info. 84 00:04:42,390 --> 00:04:44,670 Now you know how to enter commands in the shell. 85 00:04:44,670 --> 00:04:47,900 Up next, we'll look at ways to change the behavior of those commands.