Google provides a set of tools and utilities to help users manage resources hosted on GCP (Google Cloud Platform ). This set of tools is collectively referred to as Google Cloud SDK, short for Software Development Kit. The Google Cloud SDK comprises gcloud, gsutil, and bqcommand line utilities.
In this guide, we examine different ways of installing Google Cloud SDK on Ubuntu 20.04. You can install Google Cloud SDK from the official Ubuntu APT repository or using Snap packages. Let’s explore each of these installation modes.
Install Google SDK from Ubuntu repository
Google Provides an official repository from which you can install the Google SDK on your system. Ideally, this is what you would consider since it provides the latest SDK packages from the official repository.
But first, make a point of updating your package lists as shown.
$ sudo apt update
$ sudo apt install curl apt-transport-https ca-certificates gnupg
Next, create the Google SDK repository file as shown:
$ sudo vim /etc/apt/sources.list.d/google-cloud-sdk.list
And add the line below:
deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main
With the repository added, download the public key for Google Cloud as shown.
$ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
Then sync the newly added repository with Google repositories by updating the package index.
$ sudo apt update
Lastly, install the Google SDK from the Ubuntu repository as follows:
$ sudo apt install google-cloud-sdk
Type ‘Y’ to continue with the installation of Google SDK packages and dependencies.
Install Google SDK using Snap packages
A shorter and easier way of accomplishing all this is by using snap packages. By default, snap is enabled on Ubuntu 18.04 and later versions.
Thus, you can install the SDK using a single command as shown.
$ sudo snap install google-cloud-sdk --classic
This takes a bit of time since snap packages are quite bulky in size.
Initializing Google SDK
After the installation, of which any of the two methods should work, the only thing remaining is to initialize it. To do so, execute the command:
$ sudo gcloud init
The command provides you to continue. Simply press ‘Y’ to proceed. A link to log in to your Google account will be provided as shown. You can click on it directly or copy and paste it on a browser.
At this point, provide your login credentials to your Google account.
And that brings this guide to a close. We have successfully installed and setup Google Cloud SDK on Ubuntu 20.04.