1 00:00:00,000 --> 00:00:02,009 [No audio] 2 00:00:02,009 --> 00:00:05,129 File Transfer. There are many commands 3 00:00:05,129 --> 00:00:08,039 that are used to transfer files from one 4 00:00:08,039 --> 00:00:10,529 computer to another. As long as your 5 00:00:10,529 --> 00:00:12,449 computer is connected in the network, 6 00:00:12,449 --> 00:00:14,609 you could transfer files or directories 7 00:00:14,609 --> 00:00:16,529 from one server to another. Some of 8 00:00:16,529 --> 00:00:19,619 those commands are FTP, which stands for 9 00:00:19,679 --> 00:00:22,169 File Transfer Protocol. This is one of 10 00:00:22,169 --> 00:00:24,719 the old legendary commands that are used 11 00:00:24,719 --> 00:00:27,059 in many different operating system. It 12 00:00:27,059 --> 00:00:30,179 is still used in Linux, Windows and Mac, 13 00:00:30,179 --> 00:00:31,559 and in many other operating system this 14 00:00:31,559 --> 00:00:35,129 command is used. Next one, we have SCP, 15 00:00:35,129 --> 00:00:37,679 which is a Secure Copy Protocol, and 16 00:00:37,679 --> 00:00:40,379 then the next one is rsync command. 17 00:00:40,589 --> 00:00:43,679 This command is mostly used by system 18 00:00:43,679 --> 00:00:47,489 administrator to perform files backups 19 00:00:47,489 --> 00:00:50,009 from one system to another, they could 20 00:00:50,009 --> 00:00:54,029 schedule those commands through cronjob 21 00:00:54,239 --> 00:00:57,569 to copy all those sync, rsync files. 22 00:00:57,839 --> 00:01:00,839 So let's look at a few of these commands 23 00:01:00,839 --> 00:01:03,119 in our Linux environment. Here we have 24 00:01:03,149 --> 00:01:07,109 our Linux machine. And I'm logged in as 25 00:01:07,109 --> 00:01:11,459 myself. So when you want to copy a file, 26 00:01:11,459 --> 00:01:14,399 let's say I wanted to copy a file that 27 00:01:14,399 --> 00:01:17,609 is called myfirstfile, the first thing 28 00:01:17,639 --> 00:01:20,759 I have to do is type ftp, and the 29 00:01:20,759 --> 00:01:23,459 machine name that it is going to, which is 30 00:01:23,459 --> 00:01:24,749 the destination server. 31 00:01:24,749 --> 00:01:33,329 [No audio] 32 00:01:33,329 --> 00:01:37,649 Okay, so as an example, to FTP, a file 33 00:01:37,679 --> 00:01:40,469 from your server to another server, I 34 00:01:40,469 --> 00:01:42,509 have logged into my Linux machine as 35 00:01:42,509 --> 00:01:46,019 myself, and we'll see who you are, 36 00:01:46,049 --> 00:01:49,439 you are yourself. So before you try to do a 37 00:01:49,439 --> 00:01:52,229 transfer, just see if you could ping 38 00:01:53,489 --> 00:01:56,729 Google, because without internet, you 39 00:01:56,729 --> 00:01:59,639 won't be able to transfer any file. Now 40 00:01:59,669 --> 00:02:02,189 I could ping Google, it means my 41 00:02:02,189 --> 00:02:04,859 computer is on the network. Now, where 42 00:02:04,859 --> 00:02:06,989 do we have to transfer and what do we 43 00:02:06,989 --> 00:02:09,299 have to transfer. Now of course, you do 44 00:02:09,299 --> 00:02:13,649 need a server that is running FTP 45 00:02:13,649 --> 00:02:16,319 daemon, meaning your server, your 46 00:02:16,319 --> 00:02:17,939 client, and the server that you're 47 00:02:17,939 --> 00:02:20,579 trying to connect should have FTP daemon 48 00:02:20,579 --> 00:02:24,299 running and the daemon name is vsftpd. 49 00:02:25,619 --> 00:02:28,049 For this training, we do not have 50 00:02:28,079 --> 00:02:31,559 an extra external FTP. So we will try to 51 00:02:31,559 --> 00:02:34,829 connect to the Redhat FTP server just 52 00:02:34,829 --> 00:02:37,889 for training purposes. So the command to 53 00:02:37,889 --> 00:02:43,859 run is ftp ftp.redhat.com. 54 00:02:44,579 --> 00:02:46,259 And you will see, as soon as you are 55 00:02:46,259 --> 00:02:48,299 connected, it will ask you for the 56 00:02:48,299 --> 00:02:50,249 password, for the username and a 57 00:02:50,249 --> 00:02:52,799 password. So you provide the credentials 58 00:02:52,799 --> 00:02:56,129 that are given to you by the Redhat 59 00:02:56,669 --> 00:03:00,719 support. So when you enter the password 60 00:03:00,779 --> 00:03:03,209 and username, then you will enter the 61 00:03:03,209 --> 00:03:05,669 command put and the file name, and 62 00:03:05,669 --> 00:03:09,689 that's how it will be transferred to, to 63 00:03:09,689 --> 00:03:12,869 the to the FTP site. Now, if you're 64 00:03:12,869 --> 00:03:16,589 trying to transfer to a server that is 65 00:03:16,589 --> 00:03:19,049 not running the FTP daemon. So let's say 66 00:03:19,079 --> 00:03:22,799 in our environment, we have ps -ef. 67 00:03:23,669 --> 00:03:26,699 And we'll grep for ftp, and you will see 68 00:03:26,699 --> 00:03:29,849 there is no FTP daemon running, right. So 69 00:03:29,849 --> 00:03:33,419 as a training purpose, we will 70 00:03:33,419 --> 00:03:36,359 try to trasfer FTP to our own server. 71 00:03:36,689 --> 00:03:40,139 And our own server is localhost or the 72 00:03:40,139 --> 00:03:45,599 name of our host, which is MyFirstLinuxOS. So first, if you 73 00:03:45,719 --> 00:03:53,729 ping MyFirstLinuxOS, you will see 74 00:03:53,729 --> 00:03:55,529 you are getting reply right. So 75 00:03:55,529 --> 00:03:57,119 it means you are connected to your own 76 00:03:57,119 --> 00:03:59,339 machine, of course, let's clear it out. 77 00:03:59,459 --> 00:04:05,928 And now try to do ftp MyFirstLinuxOS, 78 00:04:05,928 --> 00:04:08,879 and you hit enter, you will see it 79 00:04:08,879 --> 00:04:11,459 says, connect, ftp: connect: Connection 80 00:04:11,459 --> 00:04:14,729 refused. And why is that? Because my 81 00:04:14,729 --> 00:04:17,909 server, or my Linux machine is not 82 00:04:17,909 --> 00:04:19,709 running the daemon and the demon is the 83 00:04:19,709 --> 00:04:21,959 one that listens to the incoming 84 00:04:21,959 --> 00:04:26,069 traffic. So anyway, this is how you run 85 00:04:26,069 --> 00:04:28,139 the ftp command and you transfer the 86 00:04:28,139 --> 00:04:30,719 files, and again, the purpose of doing 87 00:04:30,749 --> 00:04:34,109 FTP is if you have an issue with your 88 00:04:34,109 --> 00:04:36,269 system, and you're troubleshooting it and 89 00:04:36,269 --> 00:04:40,159 you involve support, whether it's Redhat, 90 00:04:40,159 --> 00:04:42,929 or CentOS, or Windows or whatever 91 00:04:42,929 --> 00:04:44,849 the support that you have involved, they 92 00:04:44,849 --> 00:04:47,249 would ask you to send the logs and they 93 00:04:47,249 --> 00:04:49,529 will give you the FTP server account 94 00:04:49,529 --> 00:04:51,209 information and credentials. So you 95 00:04:51,209 --> 00:04:54,256 would have to run ftp command to send logs over. 96 00:04:54,256 --> 00:04:58,594 [Author typing] 97 00:04:58,594 --> 00:05:00,119 The other command that we 98 00:05:00,209 --> 00:05:04,019 wanted to cover is SCP. Now SCP is 99 00:05:04,019 --> 00:05:06,659 basically copying a file from one 100 00:05:06,659 --> 00:05:08,669 machine to another. And of course it has 101 00:05:08,669 --> 00:05:10,409 S in front of it, so it means it's copying 102 00:05:10,409 --> 00:05:13,109 it securely. So let's take an example of 103 00:05:13,109 --> 00:05:14,909 a file that we want to transfer. Let's 104 00:05:14,909 --> 00:05:17,609 see which directory we are in. We are in 105 00:05:17,609 --> 00:05:21,089 our home directory. And let's say I have 106 00:05:21,089 --> 00:05:24,749 a file called right here, lalaland. So 107 00:05:24,779 --> 00:05:27,959 I want to take this file, copy it from 108 00:05:27,959 --> 00:05:30,689 machine A to machine B. Now, of course, 109 00:05:31,139 --> 00:05:33,839 we don't have machine B where we want to 110 00:05:33,839 --> 00:05:36,599 transfer. So we will use our own machine 111 00:05:36,719 --> 00:05:40,229 and pretend that it's a remote machine. 112 00:05:40,349 --> 00:05:43,199 So the way it works is, we will do scp 113 00:05:44,039 --> 00:05:46,529 lalaland, which is the file that I'm 114 00:05:46,529 --> 00:05:48,839 trying to copy over. So where am I 115 00:05:48,839 --> 00:05:50,519 trying to copy over? I'm trying to copy 116 00:05:50,519 --> 00:05:52,379 over to another machine, remote machine. 117 00:05:52,529 --> 00:05:54,299 So we are pretending the remote machine 118 00:05:54,329 --> 00:05:57,059 is, which is our own machine, of course, 119 00:05:57,599 --> 00:06:03,389 MyFirstLinuxOS, and then you put 120 00:06:03,989 --> 00:06:08,129 colon, which is, first is the hostname 121 00:06:08,159 --> 00:06:11,819 slash, where are you copying it to? So 122 00:06:11,819 --> 00:06:13,559 let's say I wanted to copy it to my 123 00:06:13,559 --> 00:06:16,259 home, my user directory and the 124 00:06:16,259 --> 00:06:17,849 directory you want to copy to let's say 125 00:06:17,849 --> 00:06:20,609 seinfeld. seinfeld is a directory I wanted 126 00:06:20,609 --> 00:06:25,829 to copy that file into that folder. So 127 00:06:25,859 --> 00:06:28,409 once you have that command, hit enter. 128 00:06:29,700 --> 00:06:32,700 And it says could not resolve hostname 129 00:06:32,700 --> 00:06:36,720 MyFirstLinuxOS. Oh, yeah, because 130 00:06:36,750 --> 00:06:41,340 I have misspelled first, these are the 131 00:06:41,340 --> 00:06:43,350 types of things that you probably will 132 00:06:43,350 --> 00:06:46,453 have to troubleshoot. You hit enter, my 133 00:06:47,938 --> 00:06:53,460 MyFirstLinuxOS, it's still not coming up. 134 00:06:53,460 --> 00:06:57,660 So what we do is, we'll just take out 135 00:06:57,690 --> 00:07:02,130 this part. So I'm just gonna, what I'm 136 00:07:02,130 --> 00:07:06,360 going to do is, I'm going to copy this, 137 00:07:06,600 --> 00:07:10,170 and I'm going to paste it, and then hit 138 00:07:10,170 --> 00:07:14,640 enter. Okay, so it is saying that 139 00:07:14,700 --> 00:07:20,340 connect to host myfirstlinuxos port 140 00:07:20,340 --> 00:07:23,580 22: Connection refused. So it is refusing 141 00:07:23,610 --> 00:07:27,690 a connection. Why is it refusing? Not 142 00:07:27,690 --> 00:07:31,770 sure. But let's try to do localhost. 143 00:07:31,770 --> 00:07:34,740 [Author typing] 144 00:07:34,740 --> 00:07:36,780 Yes, so you put in the password, of 145 00:07:36,780 --> 00:07:38,520 course, your own password because you 146 00:07:38,520 --> 00:07:40,350 are logging in as yourself on the 147 00:07:40,350 --> 00:07:43,650 machine as well. This is your own 148 00:07:43,650 --> 00:07:47,160 password. So once you put in the 149 00:07:47,160 --> 00:07:49,530 password, you will see it says lalaland 150 00:07:49,980 --> 00:07:54,390 100% completed, seven bytes, and did right 151 00:07:54,390 --> 00:07:56,880 and it's point five kilobytes per 152 00:07:56,880 --> 00:07:58,290 second, this is the amount of time it 153 00:07:58,290 --> 00:08:00,510 took to transfer. So it did transfers. 154 00:08:00,510 --> 00:08:03,210 Now let's verify if seinfeld directory 155 00:08:03,210 --> 00:08:06,240 has their lalaland file in it. So which 156 00:08:06,270 --> 00:08:08,190 directory I'm in? I'm in home/iafzal, 157 00:08:08,190 --> 00:08:11,190 let's go to seinfeld. And now ls, do 158 00:08:11,190 --> 00:08:13,950 ls -ltr. And you'll see, yep, 159 00:08:13,980 --> 00:08:16,680 right here. It says lalaland. There you 160 00:08:16,680 --> 00:08:21,360 go. Just to confirm, let's do 161 00:08:21,360 --> 00:08:29,490 /etc/hosts, myfirstlinuxos. So it has 162 00:08:29,490 --> 00:08:33,960 192.168.1.14. Okay, so now I know. 163 00:08:33,960 --> 00:08:37,200 So this one, I have hard coded my 164 00:08:37,200 --> 00:08:41,460 hostname with 192.168.1.14, and I'm 165 00:08:41,460 --> 00:08:44,010 sure why didn't work because, my IP 166 00:08:44,010 --> 00:08:46,440 has probably changed by now. So it's 167 00:08:46,440 --> 00:08:48,270 probably hitting some other devices in 168 00:08:48,270 --> 00:08:51,419 my network. And you see, yes, now my 169 00:08:51,419 --> 00:08:55,049 Linux machine is 1.13. And the 170 00:08:55,049 --> 00:08:57,240 reason I was not able to connect because 171 00:08:57,450 --> 00:09:01,050 1.14 is probably one of my other 172 00:09:01,050 --> 00:09:04,920 laptop, or my iPad or some other device 173 00:09:04,950 --> 00:09:08,160 in my home network that got that .14 174 00:09:08,190 --> 00:09:10,830 IP. And when I ran the scp command, it 175 00:09:10,830 --> 00:09:12,720 was actually going to that device. 176 00:09:13,200 --> 00:09:15,270 Perfect. It was a very good example. Now 177 00:09:15,270 --> 00:09:16,890 you guys learn as well that how 178 00:09:16,890 --> 00:09:20,580 important the /etc/hosts file is. 179 00:09:20,610 --> 00:09:24,000 I'll go ahead and modify that, I'll 180 00:09:24,000 --> 00:09:28,037 become root, and I will do vi /etc/hosts, 181 00:09:28,037 --> 00:09:29,790 and I'll just take these two 182 00:09:29,880 --> 00:09:32,550 entries out. I'll just leave these two, 183 00:09:32,550 --> 00:09:34,830 [Author typing] 184 00:09:34,830 --> 00:09:37,440 and close. So now if you run that 185 00:09:37,440 --> 00:09:39,090 command that we were trying to run 186 00:09:39,090 --> 00:09:41,610 before, hit up arrow key, up arrow key, oh 187 00:09:41,610 --> 00:09:44,430 no sorry, we were logged in as 188 00:09:44,430 --> 00:09:47,280 ourself, right. So now when you run that 189 00:09:47,280 --> 00:09:48,900 command, you will see it will give us a 190 00:09:48,900 --> 00:09:50,940 prompt. There you go. See right there. 191 00:09:50,970 --> 00:09:52,800 This was the one right, you hit enter. 192 00:09:53,250 --> 00:09:57,344 See it's connected. The next one is rsync, 193 00:09:57,344 --> 00:10:00,517 and this will tell you exactly, if I 194 00:10:00,517 --> 00:10:02,100 just type rsync, it will tell 195 00:10:02,100 --> 00:10:05,550 you how you can copy files. If you just 196 00:10:05,550 --> 00:10:08,340 want to itemize the changes, it will 197 00:10:08,340 --> 00:10:10,590 also tell you the progress of it. So 198 00:10:10,590 --> 00:10:14,130 this command is used, it's a very famous 199 00:10:14,130 --> 00:10:17,040 command now, and it is used by many 200 00:10:17,070 --> 00:10:20,700 system engineers to do and to perform 201 00:10:20,910 --> 00:10:23,700 file systems backup. Good luck. 202 00:10:23,700 --> 00:10:25,365 [No audio]