1 00:00:01,080 --> 00:00:02,370 Hello and welcome. 2 00:00:02,760 --> 00:00:09,120 So in this lesson, we are going to learn about some of the Linux file and directory commands. 3 00:00:09,210 --> 00:00:16,020 Now, these are the most important ones and you're going to use this very, very frequently. 4 00:00:16,350 --> 00:00:21,360 So let's quickly begin with the first command, which is the LZ command. 5 00:00:21,630 --> 00:00:24,270 So LZ stands for LIST. 6 00:00:24,270 --> 00:00:27,930 So let us see if I type the command ls and hit enter. 7 00:00:27,930 --> 00:00:29,970 What is the output that we get? 8 00:00:30,540 --> 00:00:35,310 You will be able to see whatever the content is there into your computer. 9 00:00:35,310 --> 00:00:39,940 So basically all the files and folders, which are the directories. 10 00:00:39,960 --> 00:00:45,180 As you can see, these are all the files and folders that are into my computer. 11 00:00:45,930 --> 00:00:46,560 All right. 12 00:00:46,560 --> 00:00:54,000 So if you want to see all the files in a long listing, which is basically also known as in detailed 13 00:00:54,000 --> 00:00:59,550 format, so we are going to type the command, which is ls space hyphen all. 14 00:01:00,770 --> 00:01:08,510 And you will be able to see this is the detailed listing of a file in which you are able to see more 15 00:01:08,510 --> 00:01:10,490 information about that file. 16 00:01:11,270 --> 00:01:16,370 For instance, just to make a difference if it is a file or a folder. 17 00:01:16,820 --> 00:01:19,280 By that I mean if it is a directory. 18 00:01:19,280 --> 00:01:26,530 You can also see from here, for example, you can see this file which is you want, this is a file. 19 00:01:26,540 --> 00:01:27,740 How do I know that? 20 00:01:28,610 --> 00:01:32,630 And this UFO net is a folder which is a directory. 21 00:01:32,660 --> 00:01:33,730 How do I know that? 22 00:01:33,740 --> 00:01:36,080 You can see here it is written D. 23 00:01:36,080 --> 00:01:38,850 So the file permission. 24 00:01:38,870 --> 00:01:40,550 These are the file permissions. 25 00:01:40,550 --> 00:01:48,920 And here you can see a D which denotes that this is a directory, which means it is a folder and you 26 00:01:48,920 --> 00:01:51,610 want is a file because there is no D. 27 00:01:51,620 --> 00:01:56,920 So this is one of the way to identify files and folders in Linux. 28 00:01:56,930 --> 00:02:03,680 Obviously you can obviously make out through this color coding, but this is not the best way to identify 29 00:02:03,710 --> 00:02:12,410 if this are files or folders in the Linux operating system so you can type the command ls space hyphen 30 00:02:12,410 --> 00:02:20,330 a l or hyphen a l l and you will be able to see the detailed output of that file from that. 31 00:02:20,330 --> 00:02:26,210 You can make a difference if it is a file or folder with a lot of more information as well as you can 32 00:02:26,210 --> 00:02:34,100 see over here, which also gives you the information of which is the user which has created the group 33 00:02:34,100 --> 00:02:40,430 the size as well as the date when the file was successfully created. 34 00:02:41,420 --> 00:02:42,050 Perfect. 35 00:02:42,050 --> 00:02:43,040 Let's move ahead. 36 00:02:43,040 --> 00:02:46,490 The next command that we are going to see is P.W DX. 37 00:02:46,520 --> 00:02:50,420 So PWT stands for Present Working Directory. 38 00:02:50,630 --> 00:02:55,070 Now this will show you in which the current directory you are. 39 00:02:55,160 --> 00:03:01,400 So I'm currently working into a directory which is slash route perfect. 40 00:03:01,400 --> 00:03:04,430 So let's quickly navigate into a directory for that. 41 00:03:04,430 --> 00:03:09,410 We use the command which is CD which stands for Change Directory. 42 00:03:09,920 --> 00:03:11,720 So let's change into our directory. 43 00:03:11,720 --> 00:03:19,100 And as we saw, UFO net is a directory because we saw there was a DX in front of that. 44 00:03:19,160 --> 00:03:26,300 So let's go into this directory and now you can see we have successfully navigated into this directory 45 00:03:26,300 --> 00:03:27,620 which is up for Nat. 46 00:03:28,340 --> 00:03:36,080 Also you can verify that using the command which is p dx and hit enter and you can see the present working 47 00:03:36,080 --> 00:03:40,370 directory is slash root slash UFO net. 48 00:03:41,600 --> 00:03:42,400 Perfect. 49 00:03:42,410 --> 00:03:44,750 So let's create a directory over here. 50 00:03:44,840 --> 00:03:53,000 Now, to create a new directory, you have to type the command, which is D R, which stands for make 51 00:03:53,000 --> 00:03:53,660 directory. 52 00:03:53,660 --> 00:03:57,860 So let's quickly make a directory with the name as Rohit and hit enter. 53 00:03:58,620 --> 00:04:05,790 And you can see there is no output which has displayed onto the screen but the directory has been successfully 54 00:04:05,790 --> 00:04:06,420 created. 55 00:04:06,420 --> 00:04:13,050 Let's verify using the command ls and you can see here the name which is Rohit. 56 00:04:14,190 --> 00:04:14,700 Okay. 57 00:04:14,700 --> 00:04:17,220 So far we have been doing correct. 58 00:04:17,220 --> 00:04:24,360 So let's quickly go into that directory which is CD hit and obviously we have created the directory 59 00:04:24,360 --> 00:04:25,410 just now. 60 00:04:25,560 --> 00:04:27,690 Therefore the directory is empty. 61 00:04:27,720 --> 00:04:33,750 Let's verify using the command which is ls and you can see no output over here. 62 00:04:34,080 --> 00:04:36,210 So let's quickly create a file. 63 00:04:36,210 --> 00:04:41,070 So to create an empty file you can use the command which is touch. 64 00:04:41,520 --> 00:04:45,960 So basically you are touching a file and creating an empty file. 65 00:04:45,960 --> 00:04:49,350 So let's say touch one and hit enter. 66 00:04:49,950 --> 00:04:55,350 Now let's verify if we have created a file, so let's type the command. 67 00:04:55,350 --> 00:05:04,290 LS And you can see there is a file which is one, but this file is currently empty, so let's write 68 00:05:04,290 --> 00:05:06,150 some content into this file. 69 00:05:06,150 --> 00:05:11,910 So for that there are different ways to write content into a file and different editors which you can 70 00:05:11,910 --> 00:05:12,390 use. 71 00:05:12,390 --> 00:05:18,030 So I'm going to use an editor which is Nano, so I'm just going to type the command, which is nano 72 00:05:18,030 --> 00:05:22,830 space, the file name in which you want to make changes. 73 00:05:22,830 --> 00:05:25,470 So nano space one and hit enter. 74 00:05:25,680 --> 00:05:28,110 And this is how it looks like. 75 00:05:28,110 --> 00:05:34,620 So just remember, this is like your simple notepad editor in which you can write something. 76 00:05:34,740 --> 00:05:36,480 So let us quickly write. 77 00:05:36,570 --> 00:05:40,440 This is my first. 78 00:05:43,640 --> 00:05:44,330 File. 79 00:05:44,750 --> 00:05:52,130 And let's save this for that you can simply type control se and you can see it says route one line press 80 00:05:52,130 --> 00:05:58,100 control X to come out of that file again, let's go inside that file. 81 00:05:58,250 --> 00:06:03,860 Press control SW to save control X to come out of that file. 82 00:06:04,430 --> 00:06:11,960 Now as we have created a file, empty file, and then we have written content into that file, let's 83 00:06:11,960 --> 00:06:17,410 try to verify if we have written something into that or no. 84 00:06:17,420 --> 00:06:24,680 So for that we are going to use the command which is cat and hit enter and you can see the output of 85 00:06:24,680 --> 00:06:31,490 the command cat is this is my first file and this is what we wrote into that file. 86 00:06:31,520 --> 00:06:32,150 Correct. 87 00:06:32,930 --> 00:06:33,690 Perfect. 88 00:06:33,710 --> 00:06:35,540 Now, let me clear the screen for you. 89 00:06:35,540 --> 00:06:41,840 And here you can see we have one file, so let's make a copy of this file. 90 00:06:41,840 --> 00:06:48,020 So for that, we have to type the command, which is CP and the file that you want to copy. 91 00:06:48,020 --> 00:06:51,710 So we want to copy the file, which is one perfect. 92 00:06:52,010 --> 00:06:56,030 Now if I hit enter, you can see we get an error. 93 00:06:56,120 --> 00:07:03,080 It says missing destination because we have not specified where we want to paste the file. 94 00:07:03,080 --> 00:07:05,720 We have just specified the source. 95 00:07:05,990 --> 00:07:09,740 So where do we need to paste the file? 96 00:07:09,770 --> 00:07:12,470 Let's make a folder. 97 00:07:12,770 --> 00:07:18,590 So mkdir r and let's make a folder named as shiffer and hit enter. 98 00:07:18,680 --> 00:07:26,240 And you can see here we have a directory which is Shifa and we have a file which is one, let's make 99 00:07:26,240 --> 00:07:29,930 one more directory called as Saba and hit enter. 100 00:07:29,960 --> 00:07:35,210 Now we have a file which is one which has the content. 101 00:07:35,210 --> 00:07:43,940 This is my first file and we have to empty directories so let's quickly copy the file one into Shifa 102 00:07:44,240 --> 00:07:45,980 and hit Enter. 103 00:07:46,310 --> 00:07:52,880 And you can see here is the file and there should be a file inside the directory which is Shifa. 104 00:07:52,880 --> 00:08:01,730 So let's quickly go into the directory by the command CD space, the directory in which I want to navigate 105 00:08:01,730 --> 00:08:06,860 and hit enter and let's check the present working directory. 106 00:08:06,860 --> 00:08:09,470 Yes, we are into the directory which is Shifa. 107 00:08:09,500 --> 00:08:14,840 Let's verify if there is a file and yes there is a file, let's verify the content. 108 00:08:14,840 --> 00:08:21,800 It should be the same that we have created and you can see it is exactly the same content which says 109 00:08:21,800 --> 00:08:24,260 This is my first file. 110 00:08:24,830 --> 00:08:25,430 Awesome. 111 00:08:26,090 --> 00:08:27,410 So let's go back. 112 00:08:28,780 --> 00:08:30,490 By the command, which is CD. 113 00:08:30,520 --> 00:08:30,790 Dot. 114 00:08:30,790 --> 00:08:31,140 Dot. 115 00:08:31,150 --> 00:08:32,620 So when you type the command. 116 00:08:32,650 --> 00:08:33,730 CD dot, dot. 117 00:08:33,730 --> 00:08:35,920 We are going to go one step back. 118 00:08:35,920 --> 00:08:37,780 So currently we are into this directory. 119 00:08:37,780 --> 00:08:46,000 Shifa And when we hit Enter we should be able to navigate one step back into this directory, which 120 00:08:46,000 --> 00:08:47,100 is Rohit. 121 00:08:47,890 --> 00:08:49,650 So let me hit enter. 122 00:08:49,660 --> 00:08:54,220 And you can see now I'm into this directory, which is Rohit. 123 00:08:57,180 --> 00:08:57,590 Okay. 124 00:08:57,600 --> 00:08:58,320 Perfect. 125 00:08:58,410 --> 00:09:03,820 So now we have created a file inside the directory, which is Shifa. 126 00:09:03,840 --> 00:09:05,790 So basically we have copied it. 127 00:09:05,820 --> 00:09:09,660 Now let's try to delete this file, which is one. 128 00:09:09,660 --> 00:09:14,140 So for that the command is R, which stands for remove. 129 00:09:14,160 --> 00:09:20,370 So remove one hit enter and you can see the file has been successfully removed. 130 00:09:20,670 --> 00:09:23,460 Let's quickly remove a directory as well. 131 00:09:23,460 --> 00:09:26,430 So let's say we remove the directory which is Sabah. 132 00:09:26,580 --> 00:09:29,100 So Space Sabah and hit enter. 133 00:09:29,820 --> 00:09:32,970 And you can see it gave an error. 134 00:09:32,980 --> 00:09:34,770 It says it's a directory. 135 00:09:34,920 --> 00:09:35,430 Okay. 136 00:09:35,430 --> 00:09:40,500 So we cannot remove a directory by simply typing the command arm. 137 00:09:40,530 --> 00:09:46,350 So let's remove the directory with the command, which is our m d i r. 138 00:09:46,500 --> 00:09:54,780 So Aram to delete a file ah dear, to remove a directory and let's hit enter and you can see we got 139 00:09:54,780 --> 00:10:03,120 no error and we have successfully deleted the directory and you can see there is no one, there is no 140 00:10:03,120 --> 00:10:03,820 Sabah. 141 00:10:03,840 --> 00:10:07,620 So let's delete the Shifa directory as well. 142 00:10:07,620 --> 00:10:14,490 So we have used the command which is our MD here and let's type the name Shifa and hit Enter. 143 00:10:14,850 --> 00:10:17,390 Now, this time we got a different error. 144 00:10:17,400 --> 00:10:20,510 It says the directory not empty. 145 00:10:20,520 --> 00:10:21,180 Perfect. 146 00:10:21,180 --> 00:10:29,680 So now we came to know that we cannot delete a directory which has something inside it with the command. 147 00:10:29,700 --> 00:10:32,610 Ah mdi ah ah mdi ah. 148 00:10:32,610 --> 00:10:36,440 Is only used to delete empty directories. 149 00:10:36,450 --> 00:10:37,080 Perfect. 150 00:10:37,910 --> 00:10:40,700 So how do we actually delete this now? 151 00:10:40,760 --> 00:10:41,960 It's very simple. 152 00:10:41,990 --> 00:10:48,980 I am space hyphen r f and we want to delete the directory, which is Shifa. 153 00:10:49,100 --> 00:10:54,060 So remove recursively, forcefully, whatever you want to remove. 154 00:10:54,080 --> 00:10:55,670 You can remove a file. 155 00:10:55,760 --> 00:10:57,620 You can remove empty directory. 156 00:10:57,620 --> 00:11:04,970 Or you can delete a directory which has content inside it using this command which is arm space, hyphen 157 00:11:04,970 --> 00:11:05,670 RF. 158 00:11:05,690 --> 00:11:08,910 Let's hit enter and you can see it's gone. 159 00:11:08,930 --> 00:11:11,150 Everything is deleted from here. 160 00:11:11,720 --> 00:11:15,920 So I hope you guys understood how you can use this command. 161 00:11:16,580 --> 00:11:16,970 All right. 162 00:11:16,970 --> 00:11:18,330 So this is it for this video. 163 00:11:18,350 --> 00:11:21,820 Let's go ahead and see you into the next lesson. 164 00:11:21,830 --> 00:11:22,490 Thank you.