1 00:00:00,090 --> 00:00:01,560 Hello the beautiful people. 2 00:00:01,560 --> 00:00:06,270 And welcome to this video where you're going to learn how to copy and paste files and folders using 3 00:00:06,270 --> 00:00:07,080 the command line. 4 00:00:07,080 --> 00:00:11,730 Now, this should be a nice and quick lecture with just one command, the CP command, which handles 5 00:00:11,730 --> 00:00:16,379 all the copying of files and folders in Linux, and by the end of the video you'll know how to copy 6 00:00:16,379 --> 00:00:21,300 and paste files and folders using the command line, and you'll also see how to use the CP command with 7 00:00:21,300 --> 00:00:24,900 wildcards to make copying and pasting even more awesome. 8 00:00:24,900 --> 00:00:27,150 So let's go ahead and get right into it. 9 00:00:28,540 --> 00:00:28,960 Okay. 10 00:00:28,960 --> 00:00:29,800 So here we are. 11 00:00:29,800 --> 00:00:36,100 And as you can see by the Shell prompt, I'm currently on the desktop and on the desktop I have a file 12 00:00:36,400 --> 00:00:42,760 here called file one point txt and if I open that it says hello there you beautiful people. 13 00:00:43,030 --> 00:00:44,290 I wonder how that got there. 14 00:00:44,290 --> 00:00:53,080 So let's say we wanted to copy that file to another file called file two dot txt because I'm very, 15 00:00:53,080 --> 00:00:54,340 very imaginative. 16 00:00:54,880 --> 00:01:00,280 So to copy it we need to use the c p command and the CP being short for copy. 17 00:01:00,280 --> 00:01:06,250 Now we just need to tell the copy command what we want to copy and where we want to copy it to. 18 00:01:06,250 --> 00:01:07,540 So what do we want to copy. 19 00:01:07,540 --> 00:01:13,660 Well we want to copy file one dot txt and remember I'm on the desktop already in the shell so I can 20 00:01:13,660 --> 00:01:15,340 just write file one at txt. 21 00:01:15,370 --> 00:01:23,380 If I was in the home folder I would say copy desktop such file one txt just just so that you're aware. 22 00:01:23,620 --> 00:01:25,150 So let's go to the desktop again. 23 00:01:25,270 --> 00:01:28,690 So we need to tell it what we want to copy and where we want to copy it to. 24 00:01:28,690 --> 00:01:36,700 So we want to copy far one txt and we want to copy it to another file called file to txt. 25 00:01:36,700 --> 00:01:42,160 So that's all we've got to type one to copy file one into another file called file to txt. 26 00:01:42,160 --> 00:01:46,360 And when I do that, we'll see we get a file here called file two. 27 00:01:46,480 --> 00:01:52,210 And when I open that that also says hello there, you beautiful people. 28 00:01:52,210 --> 00:01:52,720 Okay. 29 00:01:54,330 --> 00:01:58,110 So that's how you copy a file to another file, which is pretty simple. 30 00:01:58,110 --> 00:02:02,440 So how would you copy a file to another folder to one of the directory? 31 00:02:02,460 --> 00:02:04,190 Well, that's pretty simple too. 32 00:02:04,200 --> 00:02:08,639 As, as I say, the copy command, all you've got to do is tell it what you want to copy and where you 33 00:02:08,639 --> 00:02:10,039 want to copy it to. 34 00:02:10,050 --> 00:02:10,500 Okay. 35 00:02:10,500 --> 00:02:17,730 So let's say I want to copy file one into this folder called Destination. 36 00:02:18,180 --> 00:02:25,200 So all I have to do is say copy file one so far one txt and copy it to destination. 37 00:02:25,680 --> 00:02:30,240 And also let's say I also wanted to copy file two at the same time. 38 00:02:30,660 --> 00:02:36,060 So want to copy file one and file two into the destination folder. 39 00:02:36,930 --> 00:02:42,540 So you can see here that the last thing that you put as a command line argument is the destination and 40 00:02:42,540 --> 00:02:45,150 everything else that comes before that is what you want to copy. 41 00:02:45,150 --> 00:02:48,840 So I could have many, many, many different commands and many, many different files that I want to 42 00:02:48,840 --> 00:02:49,290 copy here. 43 00:02:49,290 --> 00:02:52,110 But the last one is where I want to copy them all to. 44 00:02:52,170 --> 00:02:54,690 Okay, so with that, let's go ahead and press enter. 45 00:02:54,870 --> 00:03:00,180 And when I look inside destination, we can see that we've got far one and file two. 46 00:03:00,210 --> 00:03:02,580 They have both been copied into there. 47 00:03:03,330 --> 00:03:07,680 So as you can see, this whole copying and pasting business is actually rather simple with the command 48 00:03:07,680 --> 00:03:08,010 line. 49 00:03:08,010 --> 00:03:11,010 And of course you can also do it with wildcards. 50 00:03:11,010 --> 00:03:13,110 So I'm on the desktop at the minute. 51 00:03:13,110 --> 00:03:16,800 Let's say I want to remove everything that starts with the word file. 52 00:03:16,800 --> 00:03:21,690 So if I do that, both the text files should disappear because they both begin with the word file. 53 00:03:21,690 --> 00:03:22,950 So if I do that, they are. 54 00:03:22,950 --> 00:03:23,940 They've both disappeared. 55 00:03:23,940 --> 00:03:30,570 Now I can copy and paste all the stuff from in the destination folder to the desktop by just saying 56 00:03:30,570 --> 00:03:36,330 copy destination, slash everything to this folder. 57 00:03:36,330 --> 00:03:37,980 Now how do I select this folder? 58 00:03:37,980 --> 00:03:45,720 Well, if you remember back the there's always a hidden folder in each location that refers to the folder 59 00:03:45,720 --> 00:03:46,020 that it is. 60 00:03:46,020 --> 00:03:47,730 So if I just do and that is the full stop. 61 00:03:47,730 --> 00:03:54,180 So if I just do that, that dot, what that means is copy everything from within the destination folder 62 00:03:54,450 --> 00:03:58,440 into this folder which is the desktop, which is where we currently are. 63 00:03:58,920 --> 00:04:04,590 So if I do that, if I press enter, you'll see that file one and file two have been copied and pasted 64 00:04:04,590 --> 00:04:08,400 to this location, which is represented by the full stop here. 65 00:04:08,400 --> 00:04:12,150 And if you don't remember, if I just do ls with the a option. 66 00:04:12,150 --> 00:04:17,010 You can see here that we've got these two hidden folders and the one with the one dot refers to this 67 00:04:17,010 --> 00:04:22,710 folder and the one with the double dot refers to the folder above it, which is our home folder. 68 00:04:22,710 --> 00:04:23,040 Okay. 69 00:04:23,190 --> 00:04:31,830 So I could for example, copy everything from the destination folder to the parent folder of where we 70 00:04:31,860 --> 00:04:33,600 currently are, which is the home folder. 71 00:04:33,600 --> 00:04:39,480 So if I do that and I now look in our home folder, we can see that file one and file two have been 72 00:04:39,480 --> 00:04:41,550 created in there. 73 00:04:41,550 --> 00:04:47,520 So look, wildcards work absolutely great with any command, even the copy command as well. 74 00:04:47,550 --> 00:04:48,990 So let's clear the screen. 75 00:04:48,990 --> 00:04:53,340 We have seen how to copy and paste a file into another file. 76 00:04:53,340 --> 00:04:59,070 We've seen how to copy and paste a file into a folder and we've seen how to copy and paste files from 77 00:04:59,070 --> 00:05:01,140 folders into other folders. 78 00:05:01,140 --> 00:05:05,730 The only other thing we need to know is how to copy and paste entire folders. 79 00:05:06,000 --> 00:05:11,700 So we have here this copy me folder on the desktop and that's got three files in it. 80 00:05:11,700 --> 00:05:14,230 It's got file, file B and file, see. 81 00:05:14,280 --> 00:05:14,640 Okay. 82 00:05:14,730 --> 00:05:19,650 And we want to copy this entire folder into the destination folder. 83 00:05:19,650 --> 00:05:22,560 So we don't just want the files, we want the folder as well. 84 00:05:22,560 --> 00:05:25,230 So we don't just want the chocolate, we also want the wrapper. 85 00:05:25,260 --> 00:05:25,700 Okay. 86 00:05:26,010 --> 00:05:33,120 So the way that we can do this is by giving the C p command the R option, which also stands for recursive. 87 00:05:33,150 --> 00:05:38,940 Now, if you remember from when we were deleting files and folders in the last few videos with the option 88 00:05:38,940 --> 00:05:45,300 recursive deleting meant delete that folder and everything inside it and it's very similar for the copy 89 00:05:45,300 --> 00:05:45,780 command. 90 00:05:45,780 --> 00:05:50,280 What we're saying is copy the folder and everything inside of it. 91 00:05:50,910 --> 00:05:56,730 So to actually copy the copy MI folder into the destination folder, we just type it out. 92 00:05:56,730 --> 00:06:02,010 We say, we say copy with the R option, then copy me into the destination folder. 93 00:06:02,010 --> 00:06:08,550 And if I do that and then we look inside destination, we will see that the copy me folder has been 94 00:06:08,550 --> 00:06:12,480 copied and pasted and all of the different files are inside there as well. 95 00:06:12,480 --> 00:06:13,740 All safe and sound. 96 00:06:14,710 --> 00:06:15,660 So there you have it. 97 00:06:15,670 --> 00:06:18,940 You can now copy and paste files and folders using the command line. 98 00:06:18,970 --> 00:06:20,010 It's quite easy, right? 99 00:06:20,020 --> 00:06:26,170 So as a very quick review, you saw that the CP command is what deals with copying and pasting of files 100 00:06:26,170 --> 00:06:27,190 and folders in Linux. 101 00:06:27,190 --> 00:06:32,410 And the way that it works is you have the CPP, you type CPP, then what you want to copy and you can 102 00:06:32,410 --> 00:06:33,940 have as many of those as you like. 103 00:06:33,940 --> 00:06:39,340 And then at the end, the last command line argument that you give it is your destination. 104 00:06:39,700 --> 00:06:41,320 So you can have many things that you want to copy. 105 00:06:41,320 --> 00:06:45,730 But the final thing that you give it is the single destination where you want all of those things to 106 00:06:45,730 --> 00:06:46,150 go. 107 00:06:46,180 --> 00:06:52,120 Now, if you want to copy entire folders, so not just their contents, but the actual wrapper, the 108 00:06:52,120 --> 00:06:58,360 actual folder itself, then you need to give the copy command the are option to allow it to copy entire 109 00:06:58,360 --> 00:07:02,590 folders recursively and now with copying and pasting on the way. 110 00:07:02,590 --> 00:07:07,750 Up next, what we're going to be doing is we're going to be discussing moving and renaming files and 111 00:07:07,750 --> 00:07:09,100 directories in Linux. 112 00:07:09,100 --> 00:07:13,660 And what's really interesting is that you can actually use just one command to do both of those things. 113 00:07:13,660 --> 00:07:17,230 So to learn how to move and rename files using just one command. 114 00:07:17,230 --> 00:07:19,090 I'll see you in the next video.