Steps to install gcloud on Linux [100% Working]

Linux, Tips and Tricks

Author: Omer Cakmak
Reviewer: Deepak Prasad

gcloud, a Python application, is the CLI tool for GCP. It’s a component of the Google Cloud SDK, which contains a variety of libraries and tools for interfacing with GCP.

In this article, we will explain "How to install gcloud on Linux" in two ways. First method is installing from repository, second method is using install script.


Gcloud Installation Methods

We will use the latest Ubuntu 22.04 (Debian based system) for the first method and Rocky Linux 9 (Redhat based system) for the second method. Let's talk about "How to install gcloud on Linux" with two methods.


Method-1 : Install Gcloud CLI on Ubuntu

Step-1: Update your system

First update the package list in Ubuntu:

foc@foc:~$ sudo apt update -y


Step-2: Install pre-requisite packages

Then install the necessary packages before installation:

foc@foc:~$ sudo apt install apt-transport-https ca-certificates gnupg


Step-3: Add Google Cloud Repo

Add the Google Cloud official storage address to your system.

foc@foc:~$ echo "deb [signed-by=/usr/share/keyrings/] cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Note: Create a file under /etc/apt/sources.list.d, not the /etc/apt/sources.list file where the distribution's official repository addresses are located. This is a method that will not destabilize your system. It is recommended.

Then download the key and add it to your system:

foc@foc:~$ curl | sudo tee /usr/share/keyrings/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2537  100  2537    0     0   4559      0 --:--:-- --:--:-- --:--:--  4554

After the Google Cloud repository is added, refresh the package list again:

foc@foc:~$ sudo apt update -y
Hit:1 jammy InRelease
Hit:2 jammy-updates InRelease
Get:3 jammy-backports InRelease [99.8 kB]
Get:4 cloud-sdk InRelease [6,751 B]
Get:5 cloud-sdk/main amd64 Packages [299 kB]

In this step, you should see that you are accessing "".


Step-4: Download and Install gcloud CLI

Then download gcloud from the repository:

foc@foc:~$ sudo apt install google-cloud-cli

After this command, the package is installed with its dependencies. Since you have added the Google Cloud repository to the system, you also have access to other applications in the storage.


Step-5: Verify the installation

Gcloud was installed on the system with the following version:

foc@foc:~$ gcloud version
Google Cloud SDK 395.0.0
alpha 2022.07.22
beta 2022.07.22
bq 2.0.75
bundled-python3-unix 3.9.12
core 2022.07.22
gsutil 5.11


Method - 2: Install Gcloud CLI on Rocky Linux

Step-1: Pre-requisites

Python versions you need to have on your system for Google Cloud CLI:

  • Python 3 (3.5 - 3.8, 3.7 recommended)
  • Python 2 (2,7,9 or higher)

One of the above versions must be installed on your system. To see the installed version, run the following command in terminal:

[foc@rocky9 ~]$ python --version
Python 3.9.10	


Step-2: Download gcloud cli archive

Then download the google-cloud-cli 64 bit package to the system:

[foc@rocky9 ~]$ curl -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 99.8M  100 99.8M    0     0  1985k      0  0:00:51  0:00:51 --:--:-- 1878k

Note: Below are the links for different architectural systems.

To download the 32-bit package:
For ARM systems:

Package downloaded:

[foc@rocky9 ~]$ ls

Unzip the compressed file:

[foc@rocky9 ~]$ tar -xf google-cloud-cli-395.0.0-linux-x86_64.tar.gz


Step-3: Install and setup gcloud CLI (Interactive)

Run the script using the following command:

[foc@rocky9 ~]$ ./google-cloud-sdk/
Welcome to the Google Cloud CLI!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <>. This data is
handled in accordance with our privacy policy
<>. You may choose to opt in this
collection now (by choosing 'Y' at the below prompt), or at any time in the
future by running the following command:

    gcloud config set disable_usage_reporting false

Do you want to help improve the Google Cloud CLI (y/N)?  N

Your current Google Cloud CLI version is: 395.0.0
The latest available version is: 395.0.0

│                                                 Components                                                 │
│     Status    │                         Name                         │            ID            │   Size   │
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  4.2 MiB │
│ Not Installed │ Appctl                                               │ appctl                   │ 21.0 MiB │
│ Not Installed │ Artifact Registry Go Module Package Helper           │ package-go-module        │  < 1 MiB │
│ Not Installed │ Bundled Python 3.9                                   │ bundled-python3-unix     │ 62.2 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool                     │ cbt                      │  9.8 MiB │
│ Not Installed │ Cloud Bigtable Emulator                              │ bigtable                 │  6.0 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool                      │ datalab                  │  < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator                             │ cloud-datastore-emulator │ 34.9 MiB │
│ Not Installed │ Cloud Firestore Emulator                             │ cloud-firestore-emulator │ 40.2 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator                               │ pubsub-emulator          │ 60.7 MiB │
│ Not Installed │ Cloud Run Proxy                                      │ cloud-run-proxy          │  9.0 MiB │
│ Not Installed │ Cloud SQL Proxy                                      │ cloud_sql_proxy          │  7.8 MiB │
│ Not Installed │ Cloud Spanner Emulator                               │ cloud-spanner-emulator   │ 27.2 MiB │
│ Not Installed │ Cloud Spanner Migration Tool                         │ harbourbridge            │ 14.8 MiB │
│ Not Installed │ Google Cloud Build Local Builder                     │ cloud-build-local        │  6.3 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │  1.8 MiB │
│ Not Installed │ Kustomize                                            │ kustomize                │  4.3 MiB │
│ Not Installed │ Minikube                                             │ minikube                 │ 30.6 MiB │
│ Not Installed │ Nomos CLI                                            │ nomos                    │ 25.0 MiB │
│ Not Installed │ On-Demand Scanning API extraction helper             │ local-extract            │ 12.7 MiB │
│ Not Installed │ Skaffold                                             │ skaffold                 │ 19.2 MiB │
│ Not Installed │ Terraform Tools                                      │ terraform-tools          │ 50.5 MiB │
│ Not Installed │ anthos-auth                                          │ anthos-auth              │ 19.5 MiB │
│ Not Installed │ config-connector                                     │ config-connector         │ 54.0 MiB │
│ Not Installed │ gcloud Alpha Commands                                │ alpha                    │  < 1 MiB │
│ Not Installed │ gcloud Beta Commands                                 │ beta                     │  < 1 MiB │
│ Not Installed │ gcloud app Java Extensions                           │ app-engine-java          │ 51.3 MiB │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python        │  7.8 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries)       │ app-engine-python-extras │ 26.4 MiB │
│ Not Installed │ kpt                                                  │ kpt                      │ 12.1 MiB │
│ Not Installed │ kubectl                                              │ kubectl                  │  < 1 MiB │
│ Not Installed │ kubectl-oidc                                         │ kubectl-oidc             │ 19.5 MiB │
│ Not Installed │ pkg                                                  │ pkg                      │          │
│ Installed     │ BigQuery Command Line Tool                           │ bq                       │  1.6 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │ 15.5 MiB │
│ Installed     │ Google Cloud CLI Core Libraries                      │ core                     │ 24.1 MiB │
To install or remove components at your current SDK version [395.0.0], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [395.0.0], run:
  $ gcloud components update

Modify profile to update your $PATH and enable shell command completion?

Do you want to continue (Y/n)?  Y

The Google Cloud SDK installer will now prompt you to update an rc file to bring the Google Cloud CLIs into your 

Enter a path to an rc file to update, or leave blank to use [/home/foc/.bashrc]:  
Backing up [/home/foc/.bashrc] to [/home/foc/.bashrc.backup].
[/home/foc/.bashrc] has been updated.

==> Start a new shell for the changes to take effect.
  • "Do you want to help improve the Google Cloud CLI (y/N)?" Answer "N" to the question.
  • Continue by pressing the enter key in the question "Enter a path to an rc file to update".

To install  components at your current SDK version, run:

[foc@rocky9 ~]$ ./google-cloud-sdk/bin/gcloud components install COMPONENT_ID

For remove:

[foc@rocky9 ~]$ ./google-cloud-sdk/bin/gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version, run:

[foc@rocky9 ~]$ ./google-cloud-sdk/bin/gcloud components update

Installation is complete.


Initializing the gcloud cli

After installation of the gcloud CLI, you need to initialize it so that it will interact with your Google Cloud Project resources.

Running the gcloud init command will perform many setup tasks for gcloud Cloud SDK. Next it will prompt you to log into your Google user account. Enter Y to the prompt and enter your Google Cloud account:

[foc@rocky9 ~]$ ./google-cloud-sdk/bin/gcloud init

Note: When using Ubuntu, only type gcloud init in the terminal.

Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                                  
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)?  Y

Go to the following link in your browser:

Enter authorization code:
  • Go to the link starting with https in your browser.
  • To continue with the Google Cloud SDK implementation, sign in on the page that opens.
  • When asked "Google Cloud SDK wants to access your Google Account", answer "allow".

Copy the password on the screen:

Steps to install gcloud on Linux [100% Working]

Then paste the password in "Enter authorization code: ":

Enter authorization code: 4/0AdQt8qjURcP238EbvJTaq3cdt-UxdbuN2k-GWtbFyURPKkp7kEonRTTUJMpEQAvnFSG6LQ
You are logged in as: [].

Pick cloud project to use: 
 [1] barcode-fb0c4
 [2] foc-42320
 [3] Enter a project ID
 [4] Create a new project
Please enter numeric choice or text value (must exactly match list item):

After this step, you can start a project, log in to a project.



In this tutorial we learned 2 different methods to install gcloud on different types of Linux environments. The gcloud is a command-line interface designed to interact with the Google Cloud Platform. You can use gcloud to perform lots of administrative tasks associated with the Google Cloud Platform from your local workstation (macOS, Windows, and Linux).

Some of the tasks that you can perform using gcloud CLI include:

  • Google Kubernetes Engine (GKE) clusters
  • Google Cloud SQL instances
  • Google Compute Engine instances
  • Google Cloud DNS



Google - Install the gcloud CLI


Views: 206
Omer Cakmak

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

Leave a Comment