1 00:00:00,000 --> 00:00:01,709 [No audio] 2 00:00:01,709 --> 00:00:04,859 Navigating to file system. Of course now you know a 3 00:00:04,859 --> 00:00:07,649 lot about a file system. Now we need to know how 4 00:00:07,649 --> 00:00:10,919 are we going to get into the file system? What are 5 00:00:10,919 --> 00:00:14,699 those commands that we really need to learn to 6 00:00:14,729 --> 00:00:18,149 actually go from one directory to another, get 7 00:00:18,149 --> 00:00:20,579 their file contents and find out which directory 8 00:00:20,579 --> 00:00:23,879 we are in. When navigating a Unix file system, there 9 00:00:23,879 --> 00:00:27,539 are a few important commands. Again, the number one 10 00:00:27,539 --> 00:00:30,599 command is cd which stands for change directory, 11 00:00:31,169 --> 00:00:34,949 second one is pwd, which is print working 12 00:00:34,949 --> 00:00:37,319 directory which tells you which directory you are 13 00:00:37,319 --> 00:00:41,819 currently in, and the third one is ls, which 14 00:00:41,879 --> 00:00:45,299 stands for listing which lists the contents of 15 00:00:45,299 --> 00:00:49,199 your directory or folder. cd stands for change 16 00:00:49,199 --> 00:00:52,199 directory, pwd stands for print working directory, 17 00:00:52,229 --> 00:00:56,819 and ls stands for list. Now let's look at the real 18 00:00:56,849 --> 00:01:00,779 example. I'm going to start with Windows because 19 00:01:00,929 --> 00:01:03,929 the reason I compare Windows and Linux all the 20 00:01:03,929 --> 00:01:08,699 time is because it will be a lot easier for every 21 00:01:08,699 --> 00:01:12,719 one of you to really understand the concept behind 22 00:01:12,719 --> 00:01:15,839 it. Because we actually work on Windows almost 23 00:01:15,839 --> 00:01:19,019 every day and we scroll through everything and we 24 00:01:19,019 --> 00:01:20,759 click through everything and we don't really 25 00:01:20,759 --> 00:01:24,419 realize how experts we have become. So if you 26 00:01:24,419 --> 00:01:26,639 really need to know Linux, there should be 27 00:01:26,639 --> 00:01:29,039 some comparison with Windows that I will be 28 00:01:29,039 --> 00:01:32,099 doing. So let's look at an example of Windows. 29 00:01:33,209 --> 00:01:37,709 Okay, so I have the C drive, which in Linux is 30 00:01:37,709 --> 00:01:41,609 what is the C drive for Linux is slash. When I 31 00:01:41,819 --> 00:01:45,779 want it to go into this a C drive, I will just do 32 00:01:45,779 --> 00:01:51,809 double click, and the folder comes up. And when I 33 00:01:51,809 --> 00:01:55,229 want to go into Program Files, I'll to double click, 34 00:01:55,229 --> 00:01:57,359 [No audio] 35 00:01:57,359 --> 00:02:02,429 and the folders comes up, and so on. And if I want 36 00:02:02,429 --> 00:02:05,459 to go into Windows directory, I'll just double click. 37 00:02:06,390 --> 00:02:09,270 In Linux, let's go to the Linux 38 00:02:09,270 --> 00:02:11,310 machine, I remember our Linux machine, the first 39 00:02:11,310 --> 00:02:14,340 thing I want you to do of course is become root. 40 00:02:15,420 --> 00:02:19,020 Meaning you are as yourself right now, how do you, 41 00:02:19,050 --> 00:02:21,720 how do you know you are yourself, is because first 42 00:02:21,720 --> 00:02:24,030 you see here on your prompt, you'll see your name. 43 00:02:24,360 --> 00:02:26,340 If you just still want to know your name, you 44 00:02:26,340 --> 00:02:29,520 could just type whoami, and you will see your 45 00:02:29,550 --> 00:02:32,970 username. When you become root, you have to 46 00:02:32,970 --> 00:02:37,758 type su, which means switch user, and just dash enter. 47 00:02:37,758 --> 00:02:40,650 [No audio] 48 00:02:40,650 --> 00:02:41,910 Put a new password 49 00:02:41,910 --> 00:02:45,120 [No audio] 50 00:02:45,120 --> 00:02:48,330 Okay, so you have this message that will tell you 51 00:02:48,330 --> 00:02:52,584 the last time you became root was this date, this time, and so on. 52 00:02:52,584 --> 00:02:58,080 Anyway, let's do clear, let's clear this, so 53 00:02:58,080 --> 00:03:02,760 I'm going to clear the screen. So now when you are 54 00:03:03,180 --> 00:03:05,460 in a directory, how do you know where you are. In 55 00:03:05,460 --> 00:03:09,180 Windows you can tell right? You could tell you are 56 00:03:09,180 --> 00:03:13,170 in computer local drive in Windows, it's up right here. 57 00:03:13,380 --> 00:03:15,390 But in Linux you don't know so the command that 58 00:03:15,390 --> 00:03:18,660 you're going to need is pwd. This is what, it's 59 00:03:18,660 --> 00:03:21,390 going to tell you that you are in this directory. 60 00:03:21,390 --> 00:03:24,660 [No audio] 61 00:03:24,660 --> 00:03:27,900 If you want it to go into a different directory, 62 00:03:28,500 --> 00:03:31,260 let's say you want to go to slash, which is slash, 63 00:03:32,070 --> 00:03:36,000 slash is the primary or the parent directory of 64 00:03:36,030 --> 00:03:39,750 all directories. So you type cd, which stands for 65 00:03:39,750 --> 00:03:43,650 again change directory space slash, you hit enter. 66 00:03:44,700 --> 00:03:46,890 Once you hit enter, how do you know you are in 67 00:03:46,890 --> 00:03:51,360 that directory? Again you type pwd, and it will 68 00:03:51,360 --> 00:03:54,570 tell you you are in slash directory. Now what's 69 00:03:54,600 --> 00:03:57,960 inside of this directory, we need to see that. In 70 00:03:57,960 --> 00:04:04,110 order to see that you have to type ls option l, and 71 00:04:04,140 --> 00:04:06,780 it will tells you all the listings of the 72 00:04:06,780 --> 00:04:11,370 directory and folders and files that are inside of 73 00:04:11,370 --> 00:04:17,370 this directory. In Linux, in Windows, when you are in 74 00:04:18,089 --> 00:04:21,899 My Computer you double clicking on a folder. Let's 75 00:04:21,899 --> 00:04:24,902 say you're clicking on Program Files, 76 00:04:24,902 --> 00:04:27,605 [No audio] 77 00:04:27,605 --> 00:04:33,090 move this around, and you click on any other folder, let's say 78 00:04:33,090 --> 00:04:36,420 Dell. So you notice you're just double clicking it, 79 00:04:36,600 --> 00:04:39,690 and it is taking you to that directory. In Linux, 80 00:04:39,690 --> 00:04:43,170 you don't have that. You don't have clicking. 81 00:04:43,290 --> 00:04:47,040 So what you need to do is you need to do cd. So 82 00:04:47,040 --> 00:04:49,590 you are already, what directory you are in, you are 83 00:04:49,590 --> 00:04:52,230 in root, and let's say if you want to go to a 84 00:04:52,230 --> 00:04:55,717 directory called let's say boot, 85 00:04:55,717 --> 00:04:59,721 so cd boot, boot, 86 00:05:00,690 --> 00:05:03,600 and there you are, you are in boot. Now let's say in 87 00:05:03,600 --> 00:05:06,360 this example you want to come here, you already 88 00:05:06,360 --> 00:05:09,060 see the listing of what's inside. How do I know 89 00:05:09,060 --> 00:05:11,730 the listing in Linux? All you have do is run a 90 00:05:11,730 --> 00:05:15,840 command, it's not that easy. There you go, it 91 00:05:15,840 --> 00:05:19,740 tells you this is what you have inside. By the 92 00:05:19,740 --> 00:05:21,780 way, some of the lines are chopped up a little, so 93 00:05:21,780 --> 00:05:23,910 I'm just gonna make this a little more bigger. 94 00:05:23,910 --> 00:05:27,329 [No audio] 95 00:05:27,329 --> 00:05:30,719 Okay, so you're gonna see anything that starts 96 00:05:30,719 --> 00:05:33,989 with dash, right here, it means it's a file, 97 00:05:34,109 --> 00:05:36,389 anything that starts with d, it means it's a 98 00:05:36,389 --> 00:05:41,789 directory or a folder. I want to go back to my 99 00:05:41,789 --> 00:05:44,729 root directory, but before I go back, I wanted to 100 00:05:44,729 --> 00:05:49,349 know where I am. The command is pwd, you we are 101 00:05:49,349 --> 00:05:51,569 in boot, and I want to go to slash root again. 102 00:05:51,749 --> 00:05:53,189 There are two ways you could do. You could do 103 00:05:53,189 --> 00:05:56,459 either cd slash, it will take you to slash 104 00:05:56,459 --> 00:05:59,639 directory or you could do cd.., which will 105 00:05:59,639 --> 00:06:02,939 take you one step back, one directory back. In 106 00:06:02,939 --> 00:06:05,339 Windows, how do you do that? In Windows, you could 107 00:06:05,339 --> 00:06:08,729 simply just do, you could simply press 108 00:06:08,729 --> 00:06:10,949 the back button, back button, and there you go. You 109 00:06:10,949 --> 00:06:16,199 have all that. Also, in Windows, you notice you are, 110 00:06:16,229 --> 00:06:18,899 when you double click once it is doing three 111 00:06:18,899 --> 00:06:21,389 things for you. You double click once, that is 112 00:06:21,389 --> 00:06:24,929 doing cd for you. Then automatically it's listing 113 00:06:24,929 --> 00:06:27,719 all the directories inside it's doing ls for you 114 00:06:27,719 --> 00:06:30,539 already. And now how do you know which directory 115 00:06:30,539 --> 00:06:33,059 you are in, right here on top that's how it tells 116 00:06:33,059 --> 00:06:35,279 you which directory you are in, and so it's in Windows you doing 117 00:06:35,309 --> 00:06:39,089 three things in one shot. In Linux, you actually 118 00:06:39,089 --> 00:06:43,799 have to use all three commands, one by one to see 119 00:06:43,799 --> 00:06:47,189 the same thing as you want to see in in Windows. 120 00:06:47,519 --> 00:06:52,979 So let's say if I want to go in etc, and I 121 00:06:52,979 --> 00:06:56,639 want to go into another directory which is etc 122 00:06:57,059 --> 00:07:01,829 sysconfig. So I am two directories in. How do I 123 00:07:01,829 --> 00:07:06,089 know? pwd, print working directory. It tells you, you 124 00:07:06,089 --> 00:07:09,059 are an /etc/sysconfig. Now if I wanted to go back 125 00:07:09,059 --> 00:07:13,979 to etc directory, what I would do cd.., and 126 00:07:14,129 --> 00:07:17,129 confirm if you are in etc directory, you do pwd, 127 00:07:17,609 --> 00:07:19,949 and there you go. What if you want to go one step 128 00:07:19,949 --> 00:07:24,959 back again cd.., and where you are, you 129 00:07:24,959 --> 00:07:28,439 are in root, there you go. What happened if you 130 00:07:28,439 --> 00:07:32,669 just type cd and hit enter? Okay, it did work 131 00:07:32,669 --> 00:07:34,619 because we got a prompt back we didn't get any 132 00:07:34,619 --> 00:07:38,549 error. But which directory are we again, we are in let's 133 00:07:38,549 --> 00:07:44,189 check, we are in slash root. Why, because we are, 134 00:07:44,219 --> 00:07:48,479 who we are, whoami. We are root, we are logged in 135 00:07:48,479 --> 00:07:53,189 as root. And root directory is slash root. So 136 00:07:53,189 --> 00:07:56,999 everyone, these three, first three commands that you 137 00:07:56,999 --> 00:07:59,879 really need to learn in order to navigate the file 138 00:07:59,879 --> 00:08:03,449 system. Without these three commands, you cannot do 139 00:08:03,479 --> 00:08:05,969 anything in Linux. So what are the three commands 140 00:08:05,969 --> 00:08:09,689 really quickly? First one is cd. Let's go to home. 141 00:08:09,779 --> 00:08:13,619 that's it. What's inside the home. Let's type ls 142 00:08:13,889 --> 00:08:16,919 -l. You forgot which directory you are in, 143 00:08:17,039 --> 00:08:21,089 just type pwd, you are in home. If you want to go 144 00:08:21,089 --> 00:08:22,679 to a different directory, let's say you want to go 145 00:08:22,679 --> 00:08:27,419 to, I want to see what's inside of slash. So I will 146 00:08:27,449 --> 00:08:30,479 type slash and what's inside of it, ls -l. 147 00:08:31,049 --> 00:08:33,299 These are the directories. I want to go into 148 00:08:33,328 --> 00:08:35,308 each of these directories and find out what's 149 00:08:35,308 --> 00:08:39,149 inside of let's say, I want to go to var. I hit 150 00:08:39,207 --> 00:08:41,794 enter, what's inside of the var. 151 00:08:41,794 --> 00:08:45,629 These are the directories, different type of directories. I want to go to 152 00:08:46,409 --> 00:08:50,188 file, a log directory right here. So I'll do cd 153 00:08:50,308 --> 00:08:54,509 log. What's inside of log, I have to do ls - 154 00:08:54,509 --> 00:08:57,299 l again. These are the files and directories 155 00:08:57,359 --> 00:09:00,959 inside of log directory. Okay. All right, I forgot 156 00:09:00,959 --> 00:09:04,799 where I am? where I am, pwd, /var/log, or if I want to 157 00:09:04,799 --> 00:09:08,459 go back to slash directory, you could do dot dot, 158 00:09:08,579 --> 00:09:11,639 then dot dot again, or you could just do simply cd 159 00:09:11,639 --> 00:09:15,929 slash and now where you are, you are in slash. 160 00:09:16,409 --> 00:09:19,349 Alright, so this concludes our lesson and I hope 161 00:09:19,349 --> 00:09:24,359 you have pretty much a very good idea about cd, ls, 162 00:09:24,479 --> 00:09:28,019 and pwd commands. As a homework, I would strongly 163 00:09:28,019 --> 00:09:32,699 recommend you to log into your Linux machine, go 164 00:09:32,699 --> 00:09:39,239 to cd slash, then ls -l, and I want you to go 165 00:09:39,239 --> 00:09:42,089 into each of these directories one by one, 166 00:09:42,239 --> 00:09:45,269 subdirectories, come back from a directory, find 167 00:09:45,269 --> 00:09:48,209 out the listing of the directory, and then you will 168 00:09:48,209 --> 00:09:50,506 find out exactly how to navigate the system.