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?
Click on the arrows to vote for the correct answer
A. B. C. D.C.
https://cloud.google.com/sdk/gcloud/reference/compute/copy-filesThe correct command to copy a directory and its contents from a local workstation to a Compute Engine virtual machine instance in Google Cloud Platform depends on the tool used to perform the copy operation.
Option A: gsutil cp --project "my-gcp-project" -r ~/local-scripts/ gcp-instance-name:~/server-scripts/ --zone "us-east1-b"
This command uses the gsutil
tool to copy the local directory ~/local-scripts/
and all of its contents to the Compute Engine instance gcp-instance-name
in the us-east1-b
zone. The copied directory will be named server-scripts
on the instance. The -r
option specifies that the copy operation should be performed recursively, including all subdirectories and their contents.
Option B: gsutil cp --project "my-gcp-project" -R ~/local-scripts/ gcp-instance-name:~/server-scripts/ --zone "us-east1-b"
This command is similar to option A, but it uses the -R
option instead of -r
to specify recursive copy. The gsutil
tool treats these options as equivalent.
Option C: gcloud compute scp --project "my-gcp-project" --recurse ~/local-scripts/ gcp-instance-name:~/server-scripts/ --zone "us-east1-b"
This command uses the gcloud compute scp
command to copy the local directory ~/local-scripts/
and all of its contents to the Compute Engine instance gcp-instance-name
in the us-east1-b
zone. The copied directory will be named server-scripts
on the instance. The --recurse
option specifies that the copy operation should be performed recursively, including all subdirectories and their contents.
Option D: gcloud compute mv --project "my-gcp-project" --recurse ~/local-scripts/ gcp-instance-name:~/server-scripts/ --zone "us-east1-b"
This command uses the gcloud compute mv
command to move the local directory ~/local-scripts/
and all of its contents to the Compute Engine instance gcp-instance-name
in the us-east1-b
zone. The contents will be moved to a directory named server-scripts
on the instance. This command is not suitable for copying files to an instance since it will remove the source files on the local workstation.
In conclusion, the correct command for copying a directory and its contents from a local workstation to a Compute Engine virtual machine instance in Google Cloud Platform is option A or option C.