1 00:00:00,090 --> 00:00:01,380 Hello the beautiful people. 2 00:00:01,380 --> 00:00:05,550 And welcome to this video where you're going to be learning about one of the most useful and most important 3 00:00:05,550 --> 00:00:08,700 commands on all of Linux, the fine command. 4 00:00:08,730 --> 00:00:14,880 Now, the fine command is used to execute sophisticated search tasks on your file system, and there 5 00:00:14,880 --> 00:00:19,110 is so much stuff that you can do with the fine command that we're going to break up our discussion into 6 00:00:19,110 --> 00:00:20,130 a few videos. 7 00:00:20,130 --> 00:00:23,400 And in the next few videos, what you're going to learn is you're going to learn how to use the find 8 00:00:23,400 --> 00:00:23,730 commands. 9 00:00:23,730 --> 00:00:28,650 So what the find commands default behavior is you can learn how to control the search depth that the 10 00:00:28,650 --> 00:00:30,720 find commands searches on your file system. 11 00:00:30,720 --> 00:00:32,430 You can learn how to search by type. 12 00:00:32,430 --> 00:00:38,430 So how to get the find the find to command to only return files or directories, head to search by name. 13 00:00:38,430 --> 00:00:43,440 So if you know exactly what you're looking for, you can search by name and how to search by file size. 14 00:00:43,440 --> 00:00:48,570 So you can say, Hey, find command, find me all the files that are bigger than five megabytes or smaller 15 00:00:48,570 --> 00:00:51,060 than ten kilobytes, for example, or something in between. 16 00:00:51,420 --> 00:00:55,740 And one of the really cool things about the Find Command is that once you get this big list of results, 17 00:00:55,740 --> 00:01:02,490 as you'll see in the videos, you can execute other commands or the pipelines on each of those results. 18 00:01:02,490 --> 00:01:03,900 So we're going to show you how to do that. 19 00:01:03,900 --> 00:01:09,810 And you're going to have a really powerful tool in your Linux toolkit for manipulating loads of files 20 00:01:09,810 --> 00:01:10,140 at once. 21 00:01:10,140 --> 00:01:11,070 It's going to be awesome. 22 00:01:11,070 --> 00:01:16,740 So by the end in general, you're going to be able to perform sophisticated search tasks with the find 23 00:01:16,740 --> 00:01:17,100 command. 24 00:01:17,110 --> 00:01:18,150 So that's it in a nutshell. 25 00:01:18,150 --> 00:01:23,730 And you're going to want to pay attention to this section for sure, because this may be very useful 26 00:01:23,730 --> 00:01:24,870 for your assignment. 27 00:01:24,870 --> 00:01:25,650 Hint, hint. 28 00:01:25,650 --> 00:01:26,850 So I hope you enjoy it. 29 00:01:26,850 --> 00:01:30,600 Let's go ahead and jump over into Ubuntu and start playing with the find command. 30 00:01:31,420 --> 00:01:34,000 All right, so here we are in our home directory. 31 00:01:34,000 --> 00:01:38,020 So let's just go ahead and see how the find command will work by default. 32 00:01:38,020 --> 00:01:44,320 So the default behavior of the find command, if we just go ahead and run find is to list every single 33 00:01:44,320 --> 00:01:51,790 file and every single folder that is lower down in our file system than the current folder that we're 34 00:01:51,790 --> 00:01:52,120 in. 35 00:01:52,120 --> 00:01:52,340 Okay. 36 00:01:52,450 --> 00:01:54,490 And everything inside the folder that we're in. 37 00:01:54,550 --> 00:01:54,880 Okay. 38 00:01:54,970 --> 00:02:00,190 So because we're currently in our working directory, if I just hit, if I just type, find and press 39 00:02:00,190 --> 00:02:10,150 enter, we see a big long list of every single file and every single folder that is in our home directory 40 00:02:10,150 --> 00:02:11,290 and below it. 41 00:02:11,620 --> 00:02:18,550 So it will go into every folder, every hidden folder and expand out and expand out and expand out and 42 00:02:18,550 --> 00:02:19,360 list everything. 43 00:02:19,360 --> 00:02:21,340 So for example, here we've got our pictures folder. 44 00:02:21,910 --> 00:02:28,450 It will not just show our pictures folder, it will also show that we have a folder inside the pictures 45 00:02:28,450 --> 00:02:29,620 folder called Holiday. 46 00:02:29,650 --> 00:02:35,620 We just have a file inside the pictures folder called Find Me 60 txt for example, we've got our desktop, 47 00:02:35,620 --> 00:02:42,230 we've got find me one point txt and our desktop itself videos and our videos find me three point txt. 48 00:02:42,250 --> 00:02:45,160 So I'll list out the folders and everything inside them. 49 00:02:45,160 --> 00:02:48,670 And if there are folders inside those folders then it will do exactly the same. 50 00:02:48,670 --> 00:02:52,450 It will go into those folders, expand those out, and if there's other folders in there, it will go 51 00:02:52,450 --> 00:02:55,390 into those folders and expand it out to an infinite depth. 52 00:02:55,390 --> 00:03:01,360 It will just go as deep as possible into your file system from starting where starting in the current 53 00:03:01,360 --> 00:03:02,350 directory. 54 00:03:02,740 --> 00:03:07,870 So this is an immediate difference for us between the locate command and the find command. 55 00:03:07,870 --> 00:03:14,530 So the find command will list out files and folders, but the locate command will only list files and 56 00:03:14,530 --> 00:03:18,100 the find command does not need a database in order to work. 57 00:03:18,100 --> 00:03:20,410 The find command just works right there and then. 58 00:03:20,410 --> 00:03:24,250 So it's always up to date because it operates directly on your file system. 59 00:03:24,250 --> 00:03:27,520 It doesn't use a database, so it's always up to date. 60 00:03:27,520 --> 00:03:33,070 But the one downside of that is it's slightly slower than using a database. 61 00:03:33,220 --> 00:03:34,720 So that's a trade off to bear in mind. 62 00:03:35,920 --> 00:03:42,730 So because the find command will list every single file below where you give it, you can actually also, 63 00:03:43,150 --> 00:03:47,950 for example, give it the the slash folder, the base folder for the entire system. 64 00:03:47,950 --> 00:03:53,650 And this will list every single file and every single folder on the entire system. 65 00:03:54,010 --> 00:03:58,570 So that's a fun thing to try if you're bored and you potentially want to smash your computer. 66 00:03:59,050 --> 00:04:06,100 But you know, if you give it find slash Etsy, then it will list everything on the system below Etsy. 67 00:04:06,310 --> 00:04:08,470 And you can see it's giving us files and folders. 68 00:04:08,470 --> 00:04:15,640 If I give it, find, slash home, slash Ziad, slash documents, for example, it will list out everything 69 00:04:15,640 --> 00:04:21,430 below the documents folder so we can see that it's given us the documents folder and the find me to 70 00:04:21,610 --> 00:04:23,070 txt inside there. 71 00:04:23,530 --> 00:04:33,820 And if I, if I make it our documents folder, if I make another folder, let's call it blah blah, 72 00:04:33,820 --> 00:04:37,720 let's just call it that and copy and paste into there. 73 00:04:37,720 --> 00:04:40,960 We're going to call it we're going to call this one test. 74 00:04:41,500 --> 00:04:51,100 TXT Now if I do find again with the documents folder file at home slash z, let's just do this, let's 75 00:04:51,100 --> 00:04:51,970 do the tilde. 76 00:04:52,510 --> 00:04:53,080 Okay. 77 00:04:54,100 --> 00:04:59,980 What's going to happen here is you'll see now that it's done the done the blah folder as well and it's 78 00:04:59,980 --> 00:05:03,400 gone into the blah folder to find test dot txt. 79 00:05:03,820 --> 00:05:08,890 So it said we sold it, look in the documents folder it listed out find me two and it saw another folder 80 00:05:08,890 --> 00:05:12,070 here called blah and it opened that and listed everything out inside there. 81 00:05:12,070 --> 00:05:17,680 If I make another folder called blah blah and inside there I copy and paste it. 82 00:05:17,680 --> 00:05:20,710 So it says Test two. 83 00:05:22,030 --> 00:05:22,780 Text. 84 00:05:22,810 --> 00:05:26,080 And now I just say, find everything in the documents folder. 85 00:05:26,320 --> 00:05:29,830 You'll see that it's also listing out blah blah and test two. 86 00:05:29,830 --> 00:05:36,730 So the final command is searching deeper and deeper and deeper into the file system to an infinite depth. 87 00:05:37,750 --> 00:05:39,280 So that's something to bear in mind. 88 00:05:39,280 --> 00:05:43,240 And it starts either with the current directory. 89 00:05:43,240 --> 00:05:48,970 So I can start at the home directory, which is where we are at the minute or wherever you give it. 90 00:05:48,970 --> 00:05:54,370 So if I'm start to tell it to start at the documents folder, it will start there and continually dig 91 00:05:54,370 --> 00:05:58,810 deeper into the file system until it's shown you every file and every folder. 92 00:05:58,840 --> 00:06:00,970 No matter whether they're hidden or not, it doesn't matter. 93 00:06:00,970 --> 00:06:05,620 It'll show you every file in every folder deeper than that point on the file system. 94 00:06:05,620 --> 00:06:12,580 So just to make this clear, if I go to the documents folder because I'm currently in the documents 95 00:06:12,580 --> 00:06:18,940 folder, as you can see by the P command, if now I just run the find command because the find command 96 00:06:18,940 --> 00:06:23,290 will start by default at the folder we're currently in. 97 00:06:23,290 --> 00:06:29,130 If I do that and you can see now that it is started listing out the same stuff as up here, it's solid. 98 00:06:29,140 --> 00:06:29,500 Solid as that. 99 00:06:29,500 --> 00:06:35,770 We've got the blah folder, the blah blah blah and it's going into showing us test two and test and 100 00:06:35,770 --> 00:06:42,400 find me to exactly what we were getting in our documents folder up here because we were in the documents 101 00:06:42,400 --> 00:06:44,710 folder when we ran the find command. 102 00:06:44,710 --> 00:06:50,320 So you can either be in the directory that you want to start searching from or if you're not, for example, 103 00:06:50,320 --> 00:06:52,150 we're not in the slash e.t.c. folder. 104 00:06:52,150 --> 00:06:57,910 We can start the search from there and it will search from the EDC folder and continue to go to an infinite 105 00:06:57,910 --> 00:06:59,800 depth from that point. 106 00:07:00,160 --> 00:07:01,960 So that's what the Find Command is. 107 00:07:01,960 --> 00:07:04,900 It doesn't use a database, it operates directly on your file system. 108 00:07:04,900 --> 00:07:09,220 So it's a bit slower than the locate command, but it's incredibly powerful. 109 00:07:09,220 --> 00:07:14,020 So now that you've understood the basics of what the Find Command does in the next video, we're going 110 00:07:14,020 --> 00:07:19,660 to show you how you can customize some of its behavior, starting with how you can control can control 111 00:07:19,660 --> 00:07:23,110 the depth to which it's searches and what it searches for. 112 00:07:23,470 --> 00:07:28,570 So the fine command search is from where you give it or from the current directory by default. 113 00:07:28,570 --> 00:07:32,920 And in the next video, we're going to take a look at how you can control some of the way that it searches. 114 00:07:32,920 --> 00:07:34,720 So I'll see you in the next video.