Search code examples
shellgoogle-cloud-platformterminalcloudgoogle-cloud-shell

GCP SDK changing cloud directories from local terminal


I'm trying to follow this tutorial. It seems that if I open a "cloud shell" in the browser, I can execute commands such as cd <cloud path> without any issues. However, when I try to do so from my laptop terminal I run into issues:

(base) user ~ % gsutil ls
gs://my_project/

(base) user ~ % cd gs://my_project/
cd: no such file or directory: gs://my_project/

(base) user ~ % gsutil cd gs://my_project/
CommandException: Invalid command "cd".

(base) user ~ % gcloud cd gs://my_project/
ERROR: (gcloud) Invalid choice: 'cd'.

How should one change cloud directories from a local terminal, using gcloud SDK?


Solution

  • The program gsutil does not support the concept of a current working directory. Objects are specified using the full path <protocol><bucket><object-name>.

    If you install the package gcsfuse, you can mount a Google Cloud Storage bucket as a directory. Then you can use the Linux shell command cd to move around the bucket as a file system.

    Cloud Storage FUSE

    This article shows how to set up gcsfuse on Cloud Shell:

    Unlimited persistent disk in google cloud shell