Copying Contents to a Web Server: Linux+ Exam Practice

Copy Contents to a Web Server

Question

A Linux systems administrator needs to copy the contents of a directory named 'working' on the local working system to a folder /var/www/html on a server named 'corporate-web'

Which of the following commands will allow the administrator to copy all the contents to the web server?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

https://unix.stackexchange.com/questions/232946/how-to-copy-all-files-from-a-directory-to-a-remote-directory-using-scp

The correct command for copying the contents of the working directory on the local system to the remote server corporate-web at /var/www/html is:

A. scp -r working/* webuser@corporate-web:/var/www/html

Explanation:

A. scp -r working/* webuser@corporate-web:/var/www/html:

  • scp is a command-line utility for securely copying files over a network.
  • -r option is used to copy directories recursively.
  • working/* specifies that all the contents inside the working directory should be copied.
  • webuser@corporate-web:/var/www/html specifies the remote server and the destination directory where the files should be copied.

B. tar working/* webuser@corporate-web:/var/www/html:

  • tar is a command-line utility for creating and manipulating archive files.
  • working/* specifies the files and directories to include in the archive file.
  • webuser@corporate-web:/var/www/html specifies the remote server and the destination directory where the archive file should be extracted.
  • This command creates a tar archive of the contents of working, but it does not copy the files to the remote server.

C. cp -r working/* webuser@corporate-web:/var/www/html:

  • cp is a command-line utility for copying files and directories.
  • -r option is used to copy directories recursively.
  • working/* specifies that all the contents inside the working directory should be copied.
  • webuser@corporate-web:/var/www/html specifies the remote server and the destination directory where the files should be copied.
  • This command would work if the remote server were mounted as a local file system. But since it is a remote server, scp is a better option.

D. mv working webuser@corporate-web:/var/www/html:

  • mv is a command-line utility for moving or renaming files and directories.
  • This command would move the entire working directory to /var/www/html on the remote server, but it would not copy the files inside the working directory. Also, the directory would be renamed to html.