How to install gsutil on a local machine

Allie Cliffe
  • Updated

Learn how to install the Python package gsutil for managing and moving files in Google Cloud Storage locally. 

When to use a local instance of gsutil

  • Moving files from local storage to GCS (i.e. workspace storage or external Google bucket).
  • Moving files from local storage to workspace persistent disk storage (step 1 of 2)

Step-by-step instructions to install gsutil locally

First, open a terminal running on your local system. Then, follow Google’s installation instructions for Cloud SDK - or the directions below - to install Google Cloud SDK, which includes gsutil.

To install gsutil your system will need to meet the following requirements

    • Linux/Unix, Mac OS, or Windows (XP or later)
    • Versions 5.0 and up require Python 3

Step 1. Open a terminal running on your local system.

Step 2. Run the following script to install Google Cloud SDK.

./google-cloud-sdk/install.sh

Step 3. Run gcloud init to initialize the gcloud CLI.

./google-cloud-sdk/bin/gcloud init

Step 4. After installing gsutil, it is very important to authenticate your installation using the following code:

gcloud auth login

Step 5. You'll be prompted to choose an account to continue to Google Cloud SDK.
authenticate-account-GoogleCloudSDK.png
Make sure the Google account you use is the same account associated with Terra, otherwise you will not have authorization to use some of the commands. 

Verify gsutil installationBefore downloading data using gsutil, you can use the ls command to look at the buckets you can access.

Run gsutil ls to see all of the Cloud Storage buckets under the workspace project ID.

Run gsutil ls -p [project name] to list buckets for a specific project.

What to expect

Once gsutil is installed, you can perform command-line gsutil tasks to move/copy files between local storage and your workspace bucket (or any external bucket).

Other gsutil resources

For more practice, see the gsutil tutorial.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.