1 00:00:00,180 --> 00:00:01,020 Hello there. 2 00:00:01,020 --> 00:00:01,800 You're beautiful people. 3 00:00:01,800 --> 00:00:04,980 And in this video, the time has come. 4 00:00:04,980 --> 00:00:08,910 Over the last few videos you've been learning about the structure of the Linux file system. 5 00:00:08,910 --> 00:00:12,450 You've been learning how to navigate the Linux file system using the command line. 6 00:00:12,450 --> 00:00:16,680 You've been learning about file extensions in Linux and how they differ from what you might find on 7 00:00:16,680 --> 00:00:17,760 other operating systems. 8 00:00:17,760 --> 00:00:22,770 And in the last video you've learned about wild cards and how you can use them to turbocharge your workings 9 00:00:22,770 --> 00:00:23,670 with the command line. 10 00:00:23,670 --> 00:00:28,950 But in this video, you're going to take your first step from just looking at the Linux file system 11 00:00:28,950 --> 00:00:34,860 to actually modifying it by learning how to create files and directories using the command line. 12 00:00:34,860 --> 00:00:41,100 And in this video you're going to learn how to use the touch and the mkdir commands to create files 13 00:00:41,100 --> 00:00:45,540 and directories and by the end of this video you're going to be able to create your own files and folders 14 00:00:45,540 --> 00:00:46,590 using the command line. 15 00:00:46,590 --> 00:00:51,690 And then in the video after, we're going to show you how to take what you learn here and turbocharge 16 00:00:51,690 --> 00:00:58,080 it by combining it with wild card so you can create like a bajillion files and folders in just one command. 17 00:00:58,080 --> 00:01:00,000 And that's not even an exaggeration. 18 00:01:00,000 --> 00:01:02,340 Let's go ahead and jump right into it. 19 00:01:03,060 --> 00:01:03,480 Okay. 20 00:01:03,480 --> 00:01:07,530 So the first command we want to take a look at is something called the touch command. 21 00:01:07,530 --> 00:01:11,340 And the touch command can create new empty files. 22 00:01:11,340 --> 00:01:16,590 So let's say that I want to create a new file called File one on our desktop. 23 00:01:16,590 --> 00:01:22,680 So if I just head over to the desktop and I try to create a file called File one, all we have to do 24 00:01:22,680 --> 00:01:25,170 is type touch, file one. 25 00:01:25,710 --> 00:01:29,640 And we can see here that file one has been created and it appeared. 26 00:01:30,240 --> 00:01:31,080 It's pretty awesome. 27 00:01:31,080 --> 00:01:34,320 Now you don't have to do this in the directory that you're in, by the way. 28 00:01:34,320 --> 00:01:39,690 So for example, if I did something like Touch and then said, I want to put that in the documents folder 29 00:01:39,690 --> 00:01:44,820 and make another file called Distant File inside the documents folder. 30 00:01:45,180 --> 00:01:50,490 Now, when I go ahead and take a look inside the inside the documents folder, we can see that distant 31 00:01:50,490 --> 00:01:55,740 file has been created and remember that these files here are all completely empty. 32 00:01:55,740 --> 00:02:00,300 They just blank files when you use them, when you create them using the touch command. 33 00:02:00,300 --> 00:02:01,380 So that's pretty cool. 34 00:02:01,380 --> 00:02:05,610 Right now, the files that we create with the touch command are completely empty, as I said. 35 00:02:05,610 --> 00:02:10,320 But if we want to create files that actually have some content in them, that's where we can use the 36 00:02:10,320 --> 00:02:13,020 Echo Command to redirect content into it. 37 00:02:13,020 --> 00:02:19,170 So I'm on the desktop if I want to use the echo command to make a file called hello txt and want to 38 00:02:19,170 --> 00:02:21,210 put the content the just the text. 39 00:02:21,210 --> 00:02:22,140 Hello in there. 40 00:02:22,140 --> 00:02:27,960 Then I'll just type hello and redirect that into hello text. 41 00:02:27,990 --> 00:02:29,160 Now redirection. 42 00:02:29,160 --> 00:02:34,830 When you redirect to a file that isn't made yet, the shell will automatically create that file and 43 00:02:34,830 --> 00:02:35,290 put what. 44 00:02:35,370 --> 00:02:37,950 Put what was going to go inside there inside it. 45 00:02:37,950 --> 00:02:43,680 So if I go echo hello and then redirect that to hello text the show will create the file and when we 46 00:02:43,680 --> 00:02:46,800 open it we'll see that hello is inside that file. 47 00:02:46,800 --> 00:02:49,260 So that's another way of creating files. 48 00:02:50,110 --> 00:02:50,530 Okay. 49 00:02:50,530 --> 00:02:53,440 So that's how you use the touch command to create files. 50 00:02:53,440 --> 00:02:58,320 Let's see how you might go around creating folders, making directories. 51 00:02:58,720 --> 00:03:04,990 So the way you make directories in the shell, if I just clear the screen, is with the MK Command, 52 00:03:04,990 --> 00:03:07,540 which stands for make directory. 53 00:03:07,780 --> 00:03:11,180 So make folder and it works basically the same as the touch command. 54 00:03:11,200 --> 00:03:19,210 So if we try to make a folder on our desktop called folder, then all I'd have to do is type mkdir and 55 00:03:19,210 --> 00:03:21,430 call it folder press enter. 56 00:03:21,430 --> 00:03:25,180 And we see that a new folder called folder has appeared pretty cool, right? 57 00:03:25,210 --> 00:03:26,920 Again, this can happen at a distance. 58 00:03:26,920 --> 00:03:28,870 It doesn't have to be in your current working directory. 59 00:03:28,870 --> 00:03:37,270 So if I wanted to make a folder in our pictures directory called Holiday and I press enter, then I 60 00:03:37,270 --> 00:03:38,390 can check that in two ways. 61 00:03:38,410 --> 00:03:44,950 I could press CD to go back to our home directory, go into pictures using CD, and when we take a look, 62 00:03:44,950 --> 00:03:46,570 we'll see that the holiday folder is there. 63 00:03:46,570 --> 00:03:48,850 We can have a look in our graphical user interface as well. 64 00:03:48,850 --> 00:03:53,670 We go pictures and we've got a folder called Holiday that exists right there as well. 65 00:03:53,680 --> 00:03:54,550 Pretty cool, right? 66 00:03:55,850 --> 00:03:56,510 Now you can. 67 00:03:56,510 --> 00:04:02,320 Instead of creating folders one at a time, you can actually create entire folder paths all in one go. 68 00:04:02,330 --> 00:04:10,250 So I'm back on the desktop and let's say I wanted to create this path, I wanted to create blah, slash 69 00:04:10,430 --> 00:04:17,990 thing, slash blah, but I can't go ahead and make that in one go because the show is going to give 70 00:04:17,990 --> 00:04:21,980 us an error and it's going to say that the blah folder doesn't exist. 71 00:04:22,370 --> 00:04:27,240 This is because the shell tried to go to blah then to thing and then create qibla. 72 00:04:27,950 --> 00:04:31,250 Now that's just the most ridiculous sentence in the course so far, don't you think? 73 00:04:31,400 --> 00:04:38,540 Anyway, if we tried to give the mkdir command the p option so we do mkdir the p give it the p option. 74 00:04:38,540 --> 00:04:43,070 It will then create the entire path even though none of the folders exists. 75 00:04:43,070 --> 00:04:49,640 So if we do blah slash thing, slash blam and type it like that and press enter, we'll see that. 76 00:04:49,640 --> 00:04:55,130 Now we've got blah and inside there we've got thing and inside there we've got a problem. 77 00:04:55,130 --> 00:04:55,880 So that's really cool. 78 00:04:55,880 --> 00:04:58,880 We made the entire path all in one go. 79 00:04:58,880 --> 00:04:59,750 How awesome is that? 80 00:04:59,750 --> 00:05:04,760 Right now there's something to bear in mind when creating new files or directories, and that is to 81 00:05:04,760 --> 00:05:08,030 try and avoid putting spaces in the name. 82 00:05:08,030 --> 00:05:15,050 So for example, if I create a folder called Happy Birthday, if I type, if I type mkdir happy birthday, 83 00:05:16,160 --> 00:05:16,670 you see that? 84 00:05:16,670 --> 00:05:21,770 What actually happened is we created two files, a two folder, sorry, happy and birthday. 85 00:05:21,770 --> 00:05:28,070 And that's because there was this space in between the text and that basically made it two command line 86 00:05:28,070 --> 00:05:28,880 arguments. 87 00:05:29,360 --> 00:05:35,300 We gave it one input which was happy and one input which was birthday, but we wanted to be just one 88 00:05:35,300 --> 00:05:35,870 input. 89 00:05:35,900 --> 00:05:38,000 Happy birthday, just one input. 90 00:05:38,000 --> 00:05:38,960 So how do we do that? 91 00:05:38,960 --> 00:05:46,370 Well, actually, the way you do that is you do mkdir, then surround it in quotes happy birthday. 92 00:05:46,370 --> 00:05:50,630 And when you do that, you see we get one folder called Happy Birthday. 93 00:05:50,630 --> 00:05:56,900 But just in general, having folders with our files with spaces in them is just a bit of a nightmare 94 00:05:56,900 --> 00:06:02,330 in Linux because of this whole space issue in the command line argument and all that stuff. 95 00:06:02,330 --> 00:06:02,710 Okay. 96 00:06:02,750 --> 00:06:09,230 So usually what you want to do is instead of having spaces have underscores instead. 97 00:06:09,230 --> 00:06:16,250 So instead of having Happy Space Birthday, usually what you want to do is have underscores instead 98 00:06:16,520 --> 00:06:19,100 underscores being this little, little symbol here. 99 00:06:19,100 --> 00:06:25,940 So here you can see that we have another folder but with an underscore instead of a space and that just 100 00:06:25,940 --> 00:06:30,830 makes it work a lot nicer with tab, auto completion and just loads of other stuff like that. 101 00:06:30,830 --> 00:06:33,950 It stops you messing up your command line arguments and things like that. 102 00:06:34,910 --> 00:06:40,280 Another thing, of course, I think I've mentioned this multiple times, but folders and file names 103 00:06:40,280 --> 00:06:41,750 are case sensitive in Linux. 104 00:06:41,750 --> 00:06:50,480 So if I do mkdir happy underscore birthday, that's a completely different folder to happy birthday 105 00:06:50,480 --> 00:06:54,580 in lowercase, whereas on something like windows it actually wouldn't be okay. 106 00:06:54,620 --> 00:07:03,410 So that's a quick overview of how to create files and folders using the touch and mkdir commands in 107 00:07:03,410 --> 00:07:04,070 the next video. 108 00:07:04,070 --> 00:07:04,970 I'm just going to break it here. 109 00:07:04,970 --> 00:07:08,840 In the next video, we're going to take it up a notch and start combining all this goodness with wild 110 00:07:08,840 --> 00:07:15,320 cards and a really powerful ability called brace expansion, which is going to allow us to create hundreds 111 00:07:15,320 --> 00:07:18,350 of files and folders all in one command. 112 00:07:18,350 --> 00:07:21,770 So let's go ahead and cut it right here and I'll see you in the next video.