How to install Google Cloud SDK on Linux (AlmaLinux)

Reading Time: 8 minutes

The Google Cloud Software Development Kit (SDK) is a group of tools designed to assist developers in managing resources on the Google Cloud Platform. It simplifies the development process by providing a unified interface and tools, allowing developers to deploy applications, manage cloud resources, and leverage advanced services. It enhances collaboration, scalability, and security, making it a crucial component for businesses and developers seeking to harness cloud computing benefits efficiently.

This article explores the seamless integration of the Google Cloud SDK with the AlmaLinux distribution of Linux, highlighting its transformative potential and the importance of this combination of powerful platforms without delving into detailed steps and commands. We provide an overview of the significance and implications of incorporating Google Cloud SDK within the AlmaLinux environment.

Key takeaways

Using the guidance in this article, you will learn about:

  • Installing Google Cloud SDK using package manager.
  • As another install option, installing the Google Cloud SDK using the install script.
  • Installing or adding the Google Cloud SDK components.
  • Downgrading Google Cloud SDK to a specific veriion on AlmaLinux.
  • Updating Google Cloud SDK on AlmaLinux.
  • Uninstalling Google Cloud SDK on AlmaLinux.

How to install Google Cloud SDK on AlmaLinux

Prerequisites

  • Confirm that the operating system and version are AlmaLinux OS 8.
  • Ensure you have root or sudo access to install the Google Cloud SDK.

To install Google Cloud SDK on Linux (AlmaLinux), please follow the steps in this article.

Step #1. Update your AlmaLinux system

Before installing Google Cloud SDK, you must update the AlmaLinux system to reflect the most recent changes. To update the AlmaLinux system, use the following command:

sudo dnf update

Step #2. Install the Google Cloud Software Development Kit (SDK)

Option 2.1: Install Google Cloud SDK using package manager

The most common way of installing the Google Cloud SDK is by employing the package manager.

2.1.1. Add the Google Cloud SDK repository

To add the Google Cloud SDK repository, use the following command:

echo -e "[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg" | sudo tee /etc/yum.repos.d/google-cloud-sdk.repo

2.1.2. Install the Google Cloud SDK

To install Google Cloud SDK on Linux (AlmaLinux), issue this command:

sudo dnf install google-cloud-sdk

Here is the output:

]# sudo dnf install google-cloud-sdk
Google Cloud SDK                                                                                                     28 MB/s | 155 MB     00:05
Last metadata expiration check: 0:00:53 ago on Sun 04 Feb 2024 10:02:25 AM UTC.
Dependencies resolved.
====================================================================================================================================================
 Package                                Architecture                 Version                           Repository                              Size
====================================================================================================================================================
Installing:
 google-cloud-sdk                       x86_64                       462.0.1-1                         google-cloud-sdk                       121 M

Transaction Summary
====================================================================================================================================================
Install  1 Package

Total download size: 121 M
Installed size: 652 M
Is this ok [y/N]: y
Downloading Packages:
362662fa9d56b245ec71e740ad2c320e1bda8aa924993f50c9f0557c4f84834a-google-cloud-sdk-462.0.1-1.x86_64.rpm               21 MB/s | 121 MB     00:05
----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                21 MB/s | 121 MB     00:05
Google Cloud SDK                                                                                                    4.8 kB/s | 975  B     00:00
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                            1/1
  Installing       : google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1
  Running scriptlet: google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1
  Verifying        : google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1

Installed:
  google-cloud-sdk-462.0.1-1.x86_64

Complete!

2.1.3. Initialize the Google Cloud SDK environment

To initialize the Google Cloud SDK environment, you would use the following command:

gcloud init

Here is the resulting output:

]# gcloud init
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:
    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fauthcode.html&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=k1UVUqmDlk5OCkxyecQO7uOVzm5x2D&prompt=consent&access_type=offline&code_challenge=Bskerne9mzi2AnzVBbEaFOPb6IPDcFT2StMlq13JE4o&code_challenge_method=S256

Enter authorization code:

You will receive the authorization code when you click the link in your browser. To finish the process, enter the authorization code and follow the instructions. You are well on your way to completing the install of the Google Cloud SDK. There are just a few more things to consider.

2.1.4. Verify that the Google Cloud SDK installation went as expected

To verify that the Google Cloud SDK is installed, use the following command:

gcloud version

Here is the output:

]# gcloud version
Google Cloud SDK 462.0.1
alpha 2024.02.01
beta 2024.02.01
bq 2.0.101
bundled-python3-unix 3.11.7
core 2024.02.01
gcloud-crc32c 1.0.0
gsutil 5.27

Option 2.2: Install the Google Cloud SDK using the install script

Alternatively, you can install the Google Cloud SDK using a install script. Follow the steps provided in the next sections.

2.2.1 Download and install the Google Cloud SDK

With regard to downloading and installing the Google Cloud SDK on Linux (AlmaLinux) via the install script, the following command is used:

curl https://sdk.cloud.google.com | bash

Warning: Scripts should only be run from trusted sources to avoid potential harm. Before running commands directly from the internet, verify the source.

Here is the output that comes back:

]# curl https://sdk.cloud.google.com | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   443  100   443    0     0   4815      0 --:--:-- --:--:-- --:--:--  4815
Downloading Google Cloud SDK install script: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
######################################################################## 100.0%
Running install script from: /tmp/tmp.LD1VJ83oGG/install_google_cloud_sdk.bash
which curl
curl -# -f https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
---
---
/root/google-cloud-sdk/install.sh
Welcome to the Google Cloud CLI!

2.2.2 Add the Google Cloud SDK to PATH

Add the Google Cloud SDK to your AlmaLinux system's PATH using this syntax:

export PATH=$PATH:$HOME/google-cloud-sdk/bin

Add the line above to your shell profile file (/.bashrc, /.zshrc, or /.bash_profile) to make it permanent.

2.2.3. Verify Google Cloud SDK has been successfully installed

To verify that the Google Cloud SDK has been installed, here is the command:

gcloud version

The expected output would be:

]# gcloud version
Google Cloud SDK 462.0.1
alpha 2024.02.01
beta 2024.02.01
bq 2.0.101
bundled-python3-unix 3.11.7
core 2024.02.01
gcloud-crc32c 1.0.0
gsutil 5.27

To display information and help documentation for the Google Cloud SDK, use the help command:

gcloud help

Step #3. Add the Google Cloud SDK components

3.1. List the installed components

To list the currently installed and available components, use the following command:

gcloud components list

Here is the expected output shown below:

]# gcloud components list

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

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                     Components                                                     │
├──────────────────┬──────────────────────────────────────────────────────┬──────────────────────────────┬───────────┤
│      Status      │                         Name                         │              ID              │    Size   │
├──────────────────┼──────────────────────────────────────────────────────┼──────────────────────────────┼───────────┤
│ Update Available │ Google Cloud CLI Core Libraries                      │ core                         │  22.4 MiB │
│ Not Installed    │ App Engine Go Extensions                             │ app-engine-go                │   4.7 MiB │
│ Not Installed    │ Appctl                                               │ appctl                       │  21.0 MiB │
│ Not Installed    │ Artifact Registry Go Module Package Helper           │ package-go-module            │   < 1 MiB │
│ Not Installed    │ Cloud Bigtable Command Line Tool                     │ cbt                          │  16.5 MiB │
│ Not Installed    │ Cloud Bigtable Emulator                              │ bigtable                     │   7.1 MiB │
│ Not Installed    │ Cloud Datastore Emulator                             │ cloud-datastore-emulator     │  36.2 MiB │
│ Not Installed    │ Cloud Firestore Emulator                             │ cloud-firestore-emulator     │  42.8 MiB │
│ Not Installed    │ Cloud Pub/Sub Emulator                               │ pubsub-emulator              │  62.1 MiB │
│ Not Installed    │ Cloud Run Proxy                                      │ cloud-run-proxy              │  13.3 MiB │
│ Not Installed    │ Cloud SQL Proxy                                      │ cloud_sql_proxy              │   7.8 MiB │
│ Not Installed    │ Cloud Spanner Emulator                               │ cloud-spanner-emulator       │  36.0 MiB │
│ Not Installed    │ Cloud Spanner Migration Tool                         │ harbourbridge                │  20.9 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    │ Log Streaming                                        │ log-streaming                │  13.9 MiB │
│ Not Installed    │ Minikube                                             │ minikube                     │  35.4 MiB │
│ Not Installed    │ Nomos CLI                                            │ nomos                        │  28.7 MiB │
│ Not Installed    │ On-Demand Scanning API extraction helper             │ local-extract                │  14.4 MiB │
│ Not Installed    │ Skaffold                                             │ skaffold                     │  23.4 MiB │
│ Not Installed    │ Spanner migration tool                               │ spanner-migration-tool       │  23.5 MiB │
│ Not Installed    │ Terraform Tools                                      │ terraform-tools              │  66.1 MiB │
│ Not Installed    │ anthos-auth                                          │ anthos-auth                  │  21.8 MiB │
│ Not Installed    │ config-connector                                     │ config-connector             │  56.7 MiB │
│ Not Installed    │ enterprise-certificate-proxy                         │ enterprise-certificate-proxy │   8.6 MiB │
│ Not Installed    │ gcloud app Java Extensions                           │ app-engine-java              │ 125.9 MiB │
│ Not Installed    │ gcloud app Python Extensions                         │ app-engine-python            │   8.4 MiB │
│ Not Installed    │ gcloud app Python Extensions (Extra Libraries)       │ app-engine-python-extras     │  31.5 MiB │
│ Not Installed    │ gke-gcloud-auth-plugin                               │ gke-gcloud-auth-plugin       │   7.9 MiB │
│ Not Installed    │ kpt                                                  │ kpt                          │  14.4 MiB │
│ Not Installed    │ kubectl                                              │ kubectl                      │   < 1 MiB │
│ Not Installed    │ kubectl-oidc                                         │ kubectl-oidc                 │  21.8 MiB │
│ Not Installed    │ pkg                                                  │ pkg                          │           │
│ Installed        │ BigQuery Command Line Tool                           │ bq                           │   1.6 MiB │
│ Installed        │ Bundled Python 3.11                                  │ bundled-python3-unix         │  73.8 MiB │
│ Installed        │ Cloud Storage Command Line Tool                      │ gsutil                       │  11.3 MiB │
│ Installed        │ Google Cloud CRC32C Hash Tool                        │ gcloud-crc32c                │   1.2 MiB │
│ Installed        │ gcloud Alpha Commands                                │ alpha                        │   < 1 MiB │
│ Installed        │ gcloud Beta Commands                                 │ beta                         │   < 1 MiB │
└──────────────────┴──────────────────────────────────────────────────────┴──────────────────────────────┴───────────┘

3.2. Install necessary components not listed

To add or install the Google Cloud SDK components, use the following command:

gcloud components install <component_ID>

Replace the <component_ID> placeholder shown above as per your requirement. For example, to install the kubectl component, use the following command:

gcloud components install kubectl

3.3. Remove unnecessary components

To remove the Google Cloud SDK components, use the following command:

gcloud components remove <component_ID>

Again, replace the <component_ID> placeholder shown above as per your requirement.

3.4. Update all components to the newest version

To update all the installed Google Cloud SDK components to the latest version, this is the command to use:

gcloud components update

3.5. Update all components to a specific version

To update all the installed Google Cloud SDK components to a specific version, enter the following command:

gcloud components update --version=<version>

Replace the <version> placeholder as per your specific version requirement.

How to downgrade Google Cloud SDK on AlmaLinux

If you encounter compatibility issues or require a specific version of Google Cloud SDK, you can downgrade Google Cloud SDK to a exact version, use the following command:

sudo dnf downgrade google-cloud-sdk-<version>

Replace the <version> placeholder as per your particular requirement. For example, to downgrade Google Cloud SDK to version 461.0.0, use the following command:

]# sudo dnf downgrade google-cloud-sdk-461.0.0

Here is the output you should see:

]# sudo dnf downgrade google-cloud-sdk-461.0.0
Last metadata expiration check: 0:07:01 ago on Sun 04 Feb 2024 10:02:25 AM UTC.
Dependencies resolved.
====================================================================================================================================================
 Package                                Architecture                 Version                           Repository                              Size
====================================================================================================================================================
Downgrading:
 google-cloud-sdk                       x86_64                       461.0.0-1                         google-cloud-sdk                       117 M

Transaction Summary
====================================================================================================================================================
Downgrade  1 Package

Total download size: 117 M
Is this ok [y/N]: y
Downloading Packages:
aeb1cee9bc343a805eb750462ddbba11f022b0c9e6def44276fde565bd80d8f2-google-cloud-sdk-461.0.0-1.x86_64.rpm               14 MB/s | 117 MB     00:08
----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                14 MB/s | 117 MB     00:08
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                            1/1
  Downgrading      : google-cloud-sdk-461.0.0-1.x86_64                                                                                          1/2
  Running scriptlet: google-cloud-sdk-461.0.0-1.x86_64                                                                                          1/2
  Running scriptlet: google-cloud-sdk-462.0.1-1.x86_64                                                                                          2/2
  Cleanup          : google-cloud-sdk-462.0.1-1.x86_64                                                                                          2/2
  Running scriptlet: google-cloud-sdk-462.0.1-1.x86_64                                                                                          2/2
  Verifying        : google-cloud-sdk-461.0.0-1.x86_64                                                                                          1/2
  Verifying        : google-cloud-sdk-462.0.1-1.x86_64                                                                                          2/2
Downgraded:
  google-cloud-sdk-461.0.0-1.x86_64
Complete!

How to update Google Cloud SDK on AlmaLinux

To update Google Cloud SDK, use the following command:

sudo dnf upgrade google-cloud-sdk

The output would be:

]# sudo dnf upgrade google-cloud-sdk
Last metadata expiration check: 0:12:33 ago on Sun 04 Feb 2024 10:02:25 AM UTC.
Dependencies resolved.
====================================================================================================================================================
 Package                                Architecture                 Version                           Repository                              Size
====================================================================================================================================================
Upgrading:
 google-cloud-sdk                       x86_64                       462.0.1-1                         google-cloud-sdk                       121 M

Transaction Summary
====================================================================================================================================================
Upgrade  1 Package

Total download size: 121 M
Is this ok [y/N]: y
Downloading Packages:
362662fa9d56b245ec71e740ad2c320e1bda8aa924993f50c9f0557c4f84834a-google-cloud-sdk-462.0.1-1.x86_64.rpm               18 MB/s | 121 MB     00:06
----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                18 MB/s | 121 MB     00:06
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                            1/1
  Upgrading        : google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/2
  Running scriptlet: google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/2
  Running scriptlet: google-cloud-sdk-461.0.0-1.x86_64                                                                                          2/2
  Cleanup          : google-cloud-sdk-461.0.0-1.x86_64                                                                                          2/2
  Running scriptlet: google-cloud-sdk-461.0.0-1.x86_64                                                                                          2/2
  Verifying        : google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/2
  Verifying        : google-cloud-sdk-461.0.0-1.x86_64                                                                                          2/2

Upgraded:
  google-cloud-sdk-462.0.1-1.x86_64

Complete!

How to uninstall Google Cloud SDK on AlmaLinux

To uninstall Google Cloud SDK, use the following command:

sudo dnf remove google-cloud-sdk

Here is the output:

]# sudo dnf remove google-cloud-sdk
Dependencies resolved.
====================================================================================================================================================
 Package                                Architecture                 Version                          Repository                               Size
====================================================================================================================================================
Removing:
 google-cloud-sdk                       x86_64                       462.0.1-1                        @google-cloud-sdk                       652 M

Transaction Summary
====================================================================================================================================================
Remove  1 Package

Freed space: 652 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                            1/1
  Running scriptlet: google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1
  Erasing          : google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1
  Running scriptlet: google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1
  Verifying        : google-cloud-sdk-462.0.1-1.x86_64                                                                                          1/1

Removed:
  google-cloud-sdk-462.0.1-1.x86_64

Complete!

AlmaLinux and Google Cloud SDK — symphony of integration

The article provides clear instructions for Google Cloud SDK installation on Linux (AlmaLinux), making it easy for beginners and experienced users. By smoothly integrating these technologies, customers can access advanced capabilities and utilize the power of Google Cloud services on their AlmaLinux system. The installation process is a gateway to possibilities, promoting innovation and efficiency. Users may take advantage of the full potential of Google Cloud SDK on AlmaLinux and improve their digital experience as they start on this integration journey. Liquid Web offers Affordable Hosting with High-quality plans and Expert support, complementing Google Cloud SDK capabilities. AlmaLinux, Google Cloud SDK, and Liquid Web work together to create a powerful trinity for technical integration and digital dreams.

Now, you can harmonize your solution by going with Liquid Web as your hosting provider!


Avatar for Mohammed Noufal

About the Author: Mohammed Noufal

Mohammed Noufal is a B.Tech graduate with a decade of experience in server administration and web hosting. He is a father to two daughters and finds fulfillment in their growth. In his free time, he enjoys blogging, sharing experiences, and listening to music. With a strong technical background, family commitment, and creative outlets, he represents a well-rounded life journey.

Latest Articles

In-place CentOS 7 upgrades

Read Article

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article