1 00:00:07,140 --> 00:00:08,730 - All right. Let's start. 2 00:00:08,730 --> 00:00:13,730 And let me do mkdir -p /tmp/files/pictures 3 00:00:16,620 --> 00:00:19,020 so that we have this destination directory. 4 00:00:19,020 --> 00:00:24,020 And now, I can use find files smaller than 1,000 bytes. 5 00:00:24,240 --> 00:00:27,460 It might be a good idea to go in the main page of find 6 00:00:28,664 --> 00:00:31,260 and to search for the -size option to figure out 7 00:00:31,260 --> 00:00:33,360 how to use it precisely. 8 00:00:33,360 --> 00:00:35,220 And there, we can see the size option 9 00:00:35,220 --> 00:00:39,000 as a plus n, a minus n, and an n. 10 00:00:39,000 --> 00:00:43,470 So that is for greater than, less than, or exactly. 11 00:00:43,470 --> 00:00:45,690 And also, if you use a size option, 12 00:00:45,690 --> 00:00:48,837 you should know how exactly to specify it. 13 00:00:48,837 --> 00:00:50,880 And it might be a little bit surprising, 14 00:00:50,880 --> 00:00:53,880 but the default is if you do specify a number, 15 00:00:53,880 --> 00:00:56,370 then you will search for files based 16 00:00:56,370 --> 00:01:00,540 on a size in 512-byte blocks. 17 00:01:00,540 --> 00:01:02,820 So don't specify just 1000. 18 00:01:02,820 --> 00:01:05,463 You need to specify 1000c. 19 00:01:06,522 --> 00:01:08,700 c is for bytes. 20 00:01:08,700 --> 00:01:12,390 So based on that, I think we can do it. 21 00:01:12,390 --> 00:01:16,080 And we are going to do sudo find. 22 00:01:16,080 --> 00:01:17,040 Why sudo? 23 00:01:17,040 --> 00:01:20,140 For the simple reason that I want to include files 24 00:01:21,156 --> 00:01:25,710 that are not readable for ordinary users as well. 25 00:01:25,710 --> 00:01:29,957 So sudo find /etc/ -size -1000c. 26 00:01:32,640 --> 00:01:34,860 And that is what we are going to exec. 27 00:01:34,860 --> 00:01:39,860 So exec cp {} to refer to the result of the find command 28 00:01:40,661 --> 00:01:44,210 /tmp/files/pictures. 29 00:01:48,600 --> 00:01:50,580 And of course, we need to close it 30 00:01:50,580 --> 00:01:52,440 with a backslash and semicolon. 31 00:01:52,440 --> 00:01:53,910 So here we go. 32 00:01:53,910 --> 00:01:55,953 It's asking for the sudo password. 33 00:01:56,805 --> 00:02:01,410 And CP is complaining that we did not specify the -r option 34 00:02:01,410 --> 00:02:03,090 so it's omitting directories, 35 00:02:03,090 --> 00:02:04,950 but this is what we needed to do. 36 00:02:04,950 --> 00:02:09,950 And a quick ls -(laughs) /tmp/files/ pictures will show us 37 00:02:10,800 --> 00:02:13,650 that indeed it has done it 38 00:02:13,650 --> 00:02:16,680 and it has done it successfully. 39 00:02:16,680 --> 00:02:18,720 Right. The next thing that we are going to do 40 00:02:18,720 --> 00:02:23,280 we are going to the tmp/files directory 41 00:02:23,280 --> 00:02:26,280 because we needed to create a symbolic link. 42 00:02:26,280 --> 00:02:30,810 So ln -s var /var. 43 00:02:30,810 --> 00:02:33,150 Is that the right way of doing it? 44 00:02:33,150 --> 00:02:36,960 No. That's not the right way of doing it for two reasons. 45 00:02:36,960 --> 00:02:40,320 Reason number one, it failed to create symbolic link var/var 46 00:02:40,320 --> 00:02:43,500 so it's confused about what we want to create. 47 00:02:43,500 --> 00:02:45,093 That's a permission denied. 48 00:02:47,181 --> 00:02:48,420 So permission denied. 49 00:02:48,420 --> 00:02:50,010 That is what we fixed with sudo 50 00:02:50,010 --> 00:02:52,860 but then we need to specify the right way. 51 00:02:52,860 --> 00:02:56,710 And the right way is that I want to create a symbolic link 52 00:02:57,677 --> 00:02:59,493 to the var directory, 53 00:03:00,579 --> 00:03:03,480 and the resulting symbolic link is the name var. 54 00:03:03,480 --> 00:03:05,670 So this is the command that we need. 55 00:03:05,670 --> 00:03:10,670 And if you do an ls -ld on ... Oops, an ls -ld on var, 56 00:03:10,980 --> 00:03:14,670 I need a relative file name here, not an absolute file name. 57 00:03:14,670 --> 00:03:17,550 Then we can see that this is a symbolic link pointing 58 00:03:17,550 --> 00:03:18,960 to the var directory. 59 00:03:18,960 --> 00:03:22,350 And hey, everybody, in this assignment, 60 00:03:22,350 --> 00:03:26,130 it comes automatically, but don't forget that symbolic links 61 00:03:26,130 --> 00:03:28,683 needs to contain an absolute file name. 62 00:03:29,580 --> 00:03:32,133 Then we are going to create an archive. 63 00:03:33,665 --> 00:03:37,650 So let's do sudo again, sudo tar czvf, 64 00:03:40,470 --> 00:03:44,110 and the file we create is home.tgz 65 00:03:46,198 --> 00:03:48,390 and we create the archive of the home directory. 66 00:03:48,390 --> 00:03:49,890 That should be doing it. 67 00:03:49,890 --> 00:03:53,580 And about the extension tgz, it's another commonly-seen 68 00:03:53,580 --> 00:03:56,520 extension for archives that have been made with tar 69 00:03:56,520 --> 00:03:59,940 and compressed with the gz utility. 70 00:03:59,940 --> 00:04:04,940 So if I'm using ls -l, then we can see the home.tgz has been 71 00:04:05,130 --> 00:04:10,130 created successfully with the size of 95 megabytes in total. 72 00:04:10,980 --> 00:04:13,710 And if I want to extract that, well, 73 00:04:13,710 --> 00:04:18,710 I can use mkdir /tmp/archive to first create directory. 74 00:04:21,703 --> 00:04:26,703 And then we can use sudo tar xvf of home.tgz. 75 00:04:29,100 --> 00:04:34,100 And we extract it using -C to /tmp/archive. 76 00:04:35,368 --> 00:04:39,300 The -C make sure that we move into that directly 77 00:04:39,300 --> 00:04:40,680 to put it right there. 78 00:04:40,680 --> 00:04:43,260 And, oh boy, we are getting a problem. 79 00:04:43,260 --> 00:04:44,093 What is going wrong? 80 00:04:44,093 --> 00:04:47,430 Well, what is going wrong is a so-called typo. 81 00:04:47,430 --> 00:04:50,580 Do you see that, sudo tar zvf? 82 00:04:50,580 --> 00:04:52,770 That's wrong. That should be xvf. 83 00:04:52,770 --> 00:04:54,423 And that is doing so much better. 84 00:04:55,350 --> 00:04:56,760 Let's do a final check. 85 00:04:56,760 --> 00:05:01,760 If I'm using ls on /tmp/archive, then what do we see? 86 00:05:02,130 --> 00:05:04,830 We see the contents of the home directory. 87 00:05:04,830 --> 00:05:07,413 And if I would use the tree command, 88 00:05:08,914 --> 00:05:10,560 then the tree command is showing the tree view 89 00:05:10,560 --> 00:05:12,600 and this is really the home directory. 90 00:05:12,600 --> 00:05:13,620 That's what we needed. 91 00:05:13,620 --> 00:05:15,063 And with that, we are done.