Compute Engine

gcutil Tool

This document describes installation and usage of the gcutil tool. gcutil is a command-line tool that is used to manage your Google Compute Engine resources.

If you haven't already activated Google Compute Engine, follow the Getting Started Guide.


System requirements

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.

Installing gcutil

To install gcutil:

  1. Download gcutil-1.14.2.tar.gz file.

    wget https://dl.google.com/dl/cloudsdk/release/artifacts/gcutil-1.14.2.tar.gz
  2. Extract the files.

    Run the following command to extract the tar file. This unpacks a directory named gcutil-1.14.2 in /usr/local/share.

    sudo tar xzvpf gcutil-1.14.2.tar.gz -C /usr/local/share
  3. Create a symbolic link to the gcutil binary.

    sudo ln -sf /usr/local/share/gcutil-1.14.2/gcutil /usr/local/bin/gcutil
  4. Start using 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 commands, run:

    $ gcutil help

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 gcutil

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.

  1. Run gcloud auth login to 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
    Created new window in existing browser session.

    You can also provide the --no-launch-browser flag 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:
    Enter verification code:
  2. Grant access.

    In the browser window, review the application permissions and click Accept when you are ready. If you used the --no-launch-browser flag, 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.

  3. (Optional) Next, you can set a default project to use with the tool. Since a project ID is required for every command, setting a default project saves you the hassle of repeatedly providing that information.

    To set a default project, run:

    $ 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
  4. Try a quick example, such as a gcutil listinstances command:

    $ gcutil listinstances

Next steps

That's it, you can now start using gcutil! Here are some ideas to get you started: