Question: Use the scp command and localhost as theremote host name, to copy the /etc/hosts file to the home directoryof the user account max . Remember

  1. Use the scp command and "localhost" as theremote host name, to copy the /etc/hosts file to the home directoryof the user account max.

    Remember the syntax of the scp command is: scp[[user@]remotehost:]source-file [[user@]remotehost:]target-file.Where:
    1. The parameters inside the braces ([...]) are optional, so ifyou are copying a file from your local system you don't need tospecify the [[user@]remotehost:] parameters for the source-filebecause the source-file (i.e. the /etc/host file in this step) islocal. In this example the scp command could be:

      scp /etc/hosts usr1@remotehost:

      You would need to enter the password for usr1 when prompted. Thiscommand copies the /etc/hosts file on the local system to usr1'shome directory on the remote host.
    2. If you don't specify a target-file name after the colon (:),the name of the source-file is used. For example, these commandsare equivalent:

      scp /etc/hosts usr1@remote-host:hosts
      and
      scp /etc/hosts usr1@remote-host: #note:there is no target file name specified

      You would enter the password for usr1's account on the remote hostwhen prompted for a password.
    3. If you don't specify a remote user name (usr1@ in the aboveexamples) then your account name is used by default. Forexample:

      scp /etc/hosts remotehost:

      You would enter the password for your user'saccount on the remote host when promptedfor a password. This command copies the /etc/hosts file on thelocal system to my user's home directory on the remote host.
  2. Use scp to copy and rename the /etc/hostsfile to the /tmp directory on the remote localhost system usingyour user's account on the remote system. (Note: Don't forget touse the name "localhost" for the remote system name.) Name the newfile hosts-XXX (replace XXX withyour initials).
  3. Use ssh, cd andthe ls commands to display the contents of thecopied file in step 2.
    1. Use your regular user account to login to the remote systemwith the ssh commandand localhost as the remote system name
    2. Use the cd command to change directories to/tmp
    3. Use the ls -l command (showing the owner) todisplay the contents of the /tmp directory
    4. Type exit to close the ssh networkconnection to the remote localhost and return to your localsystem
  4. Repeat step 2. using rsync in placeof scp; add the number 2 to the end of the name ofthe copied file (hosts-XXX2).
  5. Use rsync to copy the /etc/hosts file onthe client local system to your home directory onthe server remote system.
  6. Repeat step 3. The ls output should show the two files,hosts-XXX and hosts-XXX2,where XXX is replaced by your initials. Makesure that the owner shows in your listing.
  7. Take a screenshot of the VM's window showing the ls outputwindow

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!