1 00:00:00,186 --> 00:00:00,968 We'll admit, 2 00:00:00,968 --> 00:00:05,150 it's a little difficult to remember how to use some of these commands. 3 00:00:05,150 --> 00:00:07,770 It gets better as you get more practice using them. 4 00:00:07,770 --> 00:00:10,800 But even experienced shell users have to look up commands or 5 00:00:10,800 --> 00:00:12,660 options that they don't use as often. 6 00:00:13,690 --> 00:00:18,160 Fortunately, it's really easy to look up program documentation on Unix-like 7 00:00:18,160 --> 00:00:19,700 systems. 8 00:00:19,700 --> 00:00:23,030 There's a standard command called man, short for manual. 9 00:00:24,040 --> 00:00:25,760 You type the man command name, and 10 00:00:25,760 --> 00:00:29,370 then the name of the program you want more info on as an argument. 11 00:00:29,370 --> 00:00:32,570 For example, let's try bringing up info on the ls command. 12 00:00:34,240 --> 00:00:37,090 man sends its output through the less command, so 13 00:00:37,090 --> 00:00:40,250 you can use the arrow keys to scroll, and type Q to quit. 14 00:00:41,280 --> 00:00:44,599 So I'll run man ls again, to bring it back up. 15 00:00:44,599 --> 00:00:49,263 The format of the manual or man page for every program is different. 16 00:00:49,263 --> 00:00:52,513 But there are some conventions that program authors try to follow, 17 00:00:52,513 --> 00:00:55,200 when writing their documentation. 18 00:00:55,200 --> 00:00:58,360 The purpose of the program is usually listed near the top. 19 00:00:58,360 --> 00:01:02,063 It says the ls program is used the list directory contents, 20 00:01:02,063 --> 00:01:03,628 which we know to be true. 21 00:01:03,628 --> 00:01:06,207 Then it usually lists arguments the command accepts. 22 00:01:07,781 --> 00:01:11,932 OPTION means command line options, like -a or -t. 23 00:01:11,932 --> 00:01:15,890 And then the ls command accepts the names of one or more files or 24 00:01:15,890 --> 00:01:17,540 directories you want to list. 25 00:01:17,540 --> 00:01:20,030 You don't have to provide any options to ls, and 26 00:01:20,030 --> 00:01:21,960 you don't have to provide any filenames. 27 00:01:21,960 --> 00:01:25,170 That's why both OPTION and FILE are in square brackets, 28 00:01:25,170 --> 00:01:27,830 to show that those arguments are optional. 29 00:01:27,830 --> 00:01:31,822 But ls can also accept more than one option, and more than one filename. 30 00:01:31,822 --> 00:01:33,646 That's why there's an ellipsis, 31 00:01:33,646 --> 00:01:36,697 a set of of three periods, following both OPTION and FILE. 32 00:01:38,793 --> 00:01:44,162 Next, you'll usually find a description of the various options the program accepts. 33 00:01:44,162 --> 00:01:47,855 Here, you can see the -a option, or its longer synonym, --all. 34 00:01:47,855 --> 00:01:52,875 It says, this option tells ls, do not ignore entries starting with dot. 35 00:01:52,875 --> 00:01:54,732 We also know this to be true. 36 00:01:54,732 --> 00:01:56,570 If we run ls with the -a option, 37 00:01:56,570 --> 00:01:59,238 it reveals files whose names begin with a dot. 38 00:02:04,140 --> 00:02:07,739 If we scroll down further, we'll see -l, 39 00:02:07,739 --> 00:02:11,643 which is an option to use a long listing format. 40 00:02:11,643 --> 00:02:18,506 Let's try that, I'll quit out of the man page and run ls -l. 41 00:02:18,506 --> 00:02:21,897 It looks like it lists additional information about each file, 42 00:02:21,897 --> 00:02:24,986 like the user who created it, and the date it was created. 43 00:02:26,901 --> 00:02:29,472 If we scroll down still further in the man page, 44 00:02:29,472 --> 00:02:31,992 we'll see the -t option that we used before. 45 00:02:31,992 --> 00:02:35,349 It sorts files by the time they were last modified. 46 00:02:35,349 --> 00:02:38,560 There are many other options listed here, some you'll understand, and 47 00:02:38,560 --> 00:02:40,181 some you won't, and that's okay. 48 00:02:40,181 --> 00:02:43,548 Manual pages tend to be written in a very technical style. 49 00:02:43,548 --> 00:02:46,742 They're intended to be more of a reminder of how to use a command, 50 00:02:46,742 --> 00:02:48,499 rather than a tutorial in using it. 51 00:02:50,514 --> 00:02:54,203 Now, let's take a look at man pages for a couple other commands. 52 00:02:54,203 --> 00:02:56,955 Let's start with the rm command. 53 00:02:56,955 --> 00:03:01,037 We can see at the top that its purpose is to remove files or directories. 54 00:03:01,037 --> 00:03:04,798 We can see that it takes one or more options, or you can skip the option, and 55 00:03:04,798 --> 00:03:06,912 then it takes one or more files to remove. 56 00:03:09,538 --> 00:03:13,261 And if we scroll down, we can see it has a variety of options, 57 00:03:13,261 --> 00:03:16,860 including the --recursive option that we used before. 58 00:03:16,860 --> 00:03:19,910 You can see that there's both a one-letter -r version, 59 00:03:19,910 --> 00:03:23,455 as well as a double-dash version, with the word --recursive. 60 00:03:24,780 --> 00:03:27,540 Now, let's try bringing up the manual for the make directory command. 61 00:03:28,580 --> 00:03:31,800 We can see that its purpose is to make directories. 62 00:03:31,800 --> 00:03:36,650 We can see that it takes one or more options, or no options, if you prefer. 63 00:03:36,650 --> 00:03:40,676 And you can see that it takes the name of one or more directories to create. 64 00:03:40,676 --> 00:03:43,928 And if I scroll down, you can see it takes a variety of options. 65 00:03:43,928 --> 00:03:46,424 Including the -p option that we used before, 66 00:03:46,424 --> 00:03:50,150 to create the parents of the directory we're creating. 67 00:03:50,150 --> 00:03:54,114 It looks like the -p option also has a synonym, --parents. 68 00:03:55,170 --> 00:03:58,200 Even expert shell users don't bother trying to memorize 69 00:03:58,200 --> 00:03:59,940 every aspect of a command. 70 00:03:59,940 --> 00:04:03,300 They rely on web searches to help them learn which commands will solve their 71 00:04:03,300 --> 00:04:04,170 problems. 72 00:04:04,170 --> 00:04:05,850 And once they've learned to use a command, 73 00:04:05,850 --> 00:04:09,870 they rely on the man command to help them remember the details. 74 00:04:09,870 --> 00:04:13,260 So feel free to forget the command options you don't often use. 75 00:04:13,260 --> 00:04:15,540 Instead, just remember the man command.