Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
- 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:- 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. - 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. - 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.
- 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:
- 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).
- Use ssh, cd andthe ls commands to display the contents of thecopied file in step 2.
- Use your regular user account to login to the remote systemwith the ssh commandand localhost as the remote system name
- Use the cd command to change directories to/tmp
- Use the ls -l command (showing the owner) todisplay the contents of the /tmp directory
- Type exit to close the ssh networkconnection to the remote localhost and return to your localsystem
- Repeat step 2. using rsync in placeof scp; add the number 2 to the end of the name ofthe copied file (hosts-XXX2).
- Use rsync to copy the /etc/hosts file onthe client local system to your home directory onthe server remote system.
- 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.
- Take a screenshot of the VM's window showing the ls outputwindow
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started