How to do it...

Linux has a collection of tools that can help in transferring data between networked computers. We will see how a few of them work in this section:

  1. Suppose we have a myfile.txt file on the local system that we want to copy to the remote system. The command to do so as follows:
      scp myfile.txt [email protected]:~Desktop/  

Here, the remote location where the file will be copied is the Desktop directory of the user account being used to connect.

  1. When we check on the remote SSH system, we can see that the myfile.txt file has been copied successfully:

  1. Now let's suppose we have a directory,  mydata in the local system, that we want to copy to the remote system. This can be done by using the  -r  option in the command:
          scp -r mydata/ [email protected]:~Desktop/

  1. Again, we check on the remote server and see that the mydata directory has been copied with all its files:

  1. Now we will see how to copy a file from the remote system back to the local system.

First, create a file on the remote server. Our file is newfile.txt:

  1. Now, on the local system, move to the directory where you wish to copy the file.

Then run the command as shown to copy the file from the remote system to the local system, in the current directory:

          scp -r [email protected]:/home/tajinder/Desktop/newfile.txt .

  1. You can also use sftp to interactively copy the files from the remote system, using ftp commands.
  2. To do this, you first start the connection using the following command:
          sftp [email protected]

  1. Next, you can run any ftp command. In our example, we try to get the file from the remote system using the get command, as shown:
          get sample.txt /home/tajinder/Desktop

  1. In the local system, you can now check whether the file has been copied successfully or not:

  1. SSH also works through Nautilus (the default file manager for GNOME desktop). So, instead of using the command line, we can use the GNOME File Explorer to start an SSH connection with the remote system.
  2. In the GNOME File Explorer, go to File | Connect to Server.
  3. In the next window, enter the details as required and click on Connect:

  1. Now we can copy the files graphically from the remote system to the local system, or vice versa:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.213.128