1 00:00:06,660 --> 00:00:10,260 - In this video, we are going to explore the ls utility. 2 00:00:10,260 --> 00:00:12,960 So what is the ls utility? 3 00:00:12,960 --> 00:00:16,620 Well, you should start by using pwd to 4 00:00:16,620 --> 00:00:18,690 to find the name of the current directory 5 00:00:18,690 --> 00:00:21,270 and then you want to investigate what's inside. 6 00:00:21,270 --> 00:00:23,490 And that is what ls is doing. 7 00:00:23,490 --> 00:00:26,140 ls is used to list files and directories 8 00:00:27,439 --> 00:00:30,360 and ls has a couple of useful options like ls-a 9 00:00:30,360 --> 00:00:33,261 which will show hidden files as well, or ls-L 10 00:00:33,261 --> 00:00:35,850 which provides a long listing 11 00:00:35,850 --> 00:00:39,090 providing many details about your files. 12 00:00:39,090 --> 00:00:40,980 Now you will notice, and I will demonstrate 13 00:00:40,980 --> 00:00:43,800 that if you use ls -l on a directory 14 00:00:43,800 --> 00:00:45,840 now you see the contents of that directory. 15 00:00:45,840 --> 00:00:49,140 If that's not what you wanna see, use ls -ld 16 00:00:49,140 --> 00:00:50,550 that will show you the properties 17 00:00:50,550 --> 00:00:52,950 and not the contents of the directory. 18 00:00:52,950 --> 00:00:54,557 And there is ls -lrt 19 00:00:54,557 --> 00:00:57,780 which shows a time sorted list of files. 20 00:00:57,780 --> 00:00:59,940 That's a lot of options together 21 00:00:59,940 --> 00:01:02,190 but I'm putting them here on the slide together 22 00:01:02,190 --> 00:01:06,000 because this is how normally you would use a command. 23 00:01:06,000 --> 00:01:09,900 Ls -lrt is showing the last modified file 24 00:01:09,900 --> 00:01:11,280 last in the list. 25 00:01:11,280 --> 00:01:12,780 And that's the awesome solution. 26 00:01:12,780 --> 00:01:15,870 If you are trying to find out what exactly has changed 27 00:01:15,870 --> 00:01:19,050 while you were doing a certain manipulation. 28 00:01:19,050 --> 00:01:22,200 If you know which directory use ls -lrt 29 00:01:22,200 --> 00:01:25,563 and you will find the last modified file last. 30 00:01:26,640 --> 00:01:27,573 Let me show you. 31 00:01:30,496 --> 00:01:31,329 All right. 32 00:01:31,329 --> 00:01:33,360 We have already seen ls -l. 33 00:01:33,360 --> 00:01:36,120 Here is ls -l again showing a list 34 00:01:36,120 --> 00:01:40,680 of directories in this case, including their properties. 35 00:01:40,680 --> 00:01:44,370 Let me use CD without arguments to get to my home directory. 36 00:01:44,370 --> 00:01:46,830 And in the home directory I'm using ls. 37 00:01:46,830 --> 00:01:50,760 This is what we see, just a couple of directories mainly. 38 00:01:50,760 --> 00:01:52,500 If you use ls -a 39 00:01:52,500 --> 00:01:55,800 then we can see the hidden files as well. 40 00:01:55,800 --> 00:01:59,700 These are mostly configuration files that are stored to 41 00:01:59,700 --> 00:02:02,640 determine how our environment is shaped. 42 00:02:02,640 --> 00:02:05,430 We'll explore these configuration files later. 43 00:02:05,430 --> 00:02:08,460 I would like to show you ls -lrt. 44 00:02:08,460 --> 00:02:12,123 And I would like to show you in the var log directory. 45 00:02:12,123 --> 00:02:15,570 Why? Because the var log directory is a directory 46 00:02:15,570 --> 00:02:18,360 where different processes are writing logs too. 47 00:02:18,360 --> 00:02:19,752 And if I wanna see which log is the most used, 48 00:02:19,752 --> 00:02:24,752 well use ls -lrt, and you can see the last modified file is 49 00:02:26,460 --> 00:02:30,270 mentioned last, which is messages 1405. 50 00:02:30,270 --> 00:02:33,185 Notice that this is something for sent to us. 51 00:02:33,185 --> 00:02:36,388 If you do the same on Ubuntu, shall we do it on Ubuntu? 52 00:02:36,388 --> 00:02:41,388 On Ubuntu, we go to var log and I use ls -lrt. 53 00:02:43,320 --> 00:02:44,280 And what do we see? 54 00:02:44,280 --> 00:02:48,210 We see that on the Ubuntu system, the name is syslog. 55 00:02:48,210 --> 00:02:51,570 It is also one of the biggest files, 56 00:02:51,570 --> 00:02:53,497 that also says something. 57 00:02:53,497 --> 00:02:55,500 One more thing that I want to show you 58 00:02:55,500 --> 00:02:58,410 and that is ls /etc or 59 00:02:58,410 --> 00:03:00,874 ls -l /etc. 60 00:03:00,874 --> 00:03:02,490 What is that doing? 61 00:03:02,490 --> 00:03:06,180 This is showing me contents of the etc directory. 62 00:03:06,180 --> 00:03:07,860 Now, what if I don't want 63 00:03:07,860 --> 00:03:10,020 to see contents of the etc directory 64 00:03:10,020 --> 00:03:12,240 but just the properties of the directory. 65 00:03:12,240 --> 00:03:16,643 While in that case, I'm adding a d, ls -ld /etc 66 00:03:16,643 --> 00:03:20,400 and now we can see the properties of the directory 67 00:03:20,400 --> 00:03:23,970 and this ls -ld is going to be very important, 68 00:03:23,970 --> 00:03:26,520 once you are going to manage permissions 69 00:03:26,520 --> 00:03:30,150 because permissions are set often on directories. 70 00:03:30,150 --> 00:03:32,190 And if you want to see the current settings, 71 00:03:32,190 --> 00:03:35,223 ls -ld on the directory will help you.