PROFESSIONAL-CLOUD-DEVELOPER · Question #40
You need to copy directory local-scripts and all of its contents from your local workstation to a Compute Engine virtual machine instance. Which command should you use?
The correct answer is C. gcloud compute scp --project "my-gcp-project" --recurse ~/local-scripts/ gcp-instance-. The correct tool for transferring files between a local workstation and a Compute Engine VM instance is 'gcloud compute scp', which wraps SSH-based secure copy. The '--recurse' flag is required to copy a directory and all of its contents recursively. Option C uses the correct com
Question
You need to copy directory local-scripts and all of its contents from your local workstation to a Compute Engine virtual machine instance. Which command should you use?
Options
- Agsutil cp --project "my-gcp-project" -r
/local-scripts/ gcp-instance- name:/server-scripts/ --zone - Bgsutil cp --project "my-gcp-project" -R
/local-scripts/ gcp-instance- name:/server-scripts/ --zone - Cgcloud compute scp --project "my-gcp-project" --recurse ~/local-scripts/ gcp-instance-
- Dgcloud compute mv --project "my-gcp-project" --recurse ~/local-scripts/ gcp- instance-
How the community answered
(29 responses)- A3% (1)
- B3% (1)
- C83% (24)
- D10% (3)
Explanation
The correct tool for transferring files between a local workstation and a Compute Engine VM instance is 'gcloud compute scp', which wraps SSH-based secure copy. The '--recurse' flag is required to copy a directory and all of its contents recursively. Option C uses the correct command and flag. Option D incorrectly uses 'gcloud compute mv', which is not a valid gcloud command for this purpose. Options A and B use 'gsutil cp', which is for interacting with Google Cloud Storage (GCS) buckets - not for copying files directly to VM instances. The syntax 'gcp-instance-name:~/...' is a Compute Engine SCP syntax, not a GCS path.
Topics
Community Discussion
No community discussion yet for this question.