This document describes installation and usage of the
a command-line tool that is used to manage your Google Compute Engine resources.
If you haven't already activated Google Compute Engine, you must follow the Sign Up steps.
gcutil runs on UNIX-based operating systems such as Linux and Mac OS X. To use
gcutil, you must have Python 2.6.x or 2.7.x installed on your computer.
gcutil does not support Python 3.x. Python is installed by default on most
Linux distributions and Mac OS X.
This section discusses how to install
gcutil on your computer.
gcutil is distributed as part of the Cloud SDK, which contains tools and libraries for managing resources on Google Cloud Platform.
Installing on Linux or Mac OS X
Download and install the Cloud SDK.
You can download and install the Cloud SDK using the following command:
$ curl https://sdk.cloud.google.com | bash
Alternatively, if you do not want to use
curl, you can download and unzip the package manually:
- Download google-cloud-sdk.zip
Unzip the file:
$ unzip google-cloud-sdk.zip
Run the installation script:
Follow the prompts to complete the setup. When prompted if you would like to update your system path, select
Restart your terminal to allow changes to your
PATHto take affect.
You can also run
source ~/.<bash-profile-file>if you want to avoid restarting your terminal.
Authenticate to the Google Cloud
platform by running:
$ gcloud auth login
Installing on Windows
For additional information on authenticating with the Cloud SDK, such as if you are working in a terminal session on another machine, see the following section.
Authenticating to Google Compute Engine
Google Compute Engine uses OAuth2 to authenticate and
authorize access. Before you can use
gcutil, you must first authorize the
Cloud SDK on your behalf to access your project and acquire an auth token. You
won't need to repeat these steps unless you delete your stored credentials file
or remove Google Compute Engine access to your Google account.
gcloud auth loginto request a token. This command prints a URL and opens a browser window to request access to your project.
$ gcloud auth login Your browser has been opened to visit: https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.co%2 Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbigquery+https %3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com% Fauth%2Fdevstorage.full_control+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuser... Created new window in existing browser session.
You can also provide the
--no-launch-browserflag if your browser doesn't automatically load the URL. If you provide this flag, the tool will print out a verification code that you can copy and paste into a browser, instead of opening a new browser window.
$ gcloud auth login --no-launch-browser Go to the following link in your browser: https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.co%2 Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbigquery+https %3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com% Fauth%2Fdevstorage.full_control+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuser... Enter verification code:
In the browser window, review the application permissions and click Accept when you are ready. If you used the
--no-launch-browserflag, copy and paste the printed code on the next page onto the command line. Otherwise, the code will automatically be sent to the command line without any additional action on your part.
(Optional) Next, the tool will prompt you for a project ID to use as your default project. Enter the ID of the project you want to use for Google Compute Engine:
You can list your projects and create new ones in the Google Cloud console at https://cloud.google.com/console. If you have a project ready, you can enter it now. Enter a cloud project id (or leave blank to not set): your_project_id
If you do not want to select a default project at this time, you can leave the prompt blank. To set your project ID later, run the following command at any time:
$ gcloud config set project <new-project-id>
Similarly, to unset your project ID, run:
$ gcloud config unset project
You can also view your settings, including your project ID:
$ gcloud config list
Try a quick example, such as a
$ gcutil listinstances
Upgrading gcutil on Compute Engine instances
Currently, Compute Engine instances come preinstalled with the Cloud
SDK. If you need to keep the stand-alone
gcutil version, use the following
instructions to keep the tool updated to the latest version.
Download the latest gcutil-1.14.2.tar.gz file.
Extract the files.
Run the following command to extract the tar file. This unpacks a directory named
sudo tar xzvpf gcutil-1.14.2.tar.gz -C /usr/local/share
Create a symbolic link to the
sudo ln -sf /usr/local/share/gcutil-1.14.2/gcutil /usr/local/bin/gcutil
If you modified your system path, restart your shell before continuing so the changes can take effect. To see a list of available
$ gcutil help
That's it, you can now start using
gcutil! Here are some ideas to
get you started: