Wiki > gsutil
Introduction
gsutil is a tool written in Python that lets you access the Google Storage cloud from the command line. It allows you to do the following:
- Create and delete buckets.
- Upload, download, and delete objects.
- List buckets and objects.
- Move, copy, and rename objects.
- Edit object and bucket ACLs.
This guide will cover how to install gsutil onto your slot. It won't go into detail in how to set up Google Cloud Platform, however.
Installation
-
Connect to your slot through SSH
-
Create the installation directory for gsutil
mkdir ~/.config/gsutil
-
Download the gsutil source
wget https://storage.googleapis.com/pub/gsutil.tar.gz
-
Extract the source and enter the directory
tar -zxf gsutil.tar.gz; cd gsutil
-
Configure gsutil to work with your Google Cloud Platform. Follow the steps in the configure process, it is self explanatory.
gsutil config
-
Add the following line to
~/.bashrc
to add the executable to your PATH environment variable. This will allow you to simply typegsutil
to use gsutil.export PATH=${PATH}:~/.config/gsutil/
-
Reload your
~/.bashrc
to be able to use the newly added commands.source ~/.bashrc
-
(Optional) Clean up the setup files.
cd .. rm -rf gsutil gsutil.tar.gz
gsutil should now be installed in ~/.config/gsutil/
. The next part shall detail how one might use it.
Use
To use gsutil, simply do the following:
gsutil <command>
To view the list of available commands:
gsutil help
Copying file to a Google Cloud Platform Storage Bucket using gsutil
This short guide will detail how to copy a file to a Storage Bucket using gsutil.
-
Create a file to copy to the Storage Bucket.
touch testfile
-
Copy the file to the Storage bucket using gsutil.
gsutil cp testfile gs://my_bucket
The file should successfully transfer to the Storage Bucket.
This completes the guide on how to set up gsutil on your slot.
Full detailed information about gsutil can be found on the gsutil Tool Page.