Linux

How To Install Google Cloud SDK on a Linux System

google-sdk-feature

Utilizing a command-line interface, you may create a virtual machine or environment for programming and software testing using the Google Cloud SDK (Software Development Kit), a cloud-based API system. It is Google-built and is housed in Google Cloud Storage. For free Google Cloud SDK signups in the past, Google would grant credit. Unfortunately, Google seems to have disabled those free functions. The Google Cloud SDK is an easy-to-use virtual platform for releasing and testing your code if you’re a software developer or tester. The Google Cloud SDK may be installed on your Linux machine to provide a superior CLI-based interface over the cloud software development kit’s web-based counterpart.

On the official Linux repository, you may find the Google software development kit. It may be installed via the script, Snap, or repository methods. In this post, we’ll look at installing and getting started with the Google Cloud SDK on Linux servers running Ubuntu. Previous guides can be found here: How to install Golang on a Linux System and how to install and configure JIRA on Linux and how to install Gradle on Ubuntu, also How to create multiple users and set passwords for each user in Linux, and how to install Sysinternals from the Microsoft Store and How to install and configure JIRA on Linux

Benefits of Google Cloud SDK

  1. It is made up of the command-line utilities gsutil, gcloud, and bq. The Cloud SDK includes an automated download of the gcloudtool.
  2. Python 2.7.x is necessary for Google Cloud SDK to operate on the supported operating systems of Windows, Linux, and macOS.
  3. Utilizes client libraries for Java, Python, Node.js, Ruby, Go, NET, and PHP to integrate with APIs.
  4. Using Google Cloud CLI, you may script or interact with cloud resources at scale.
  5. Spanner, Bigtable, Pub/Sub, and Datastore emulation can speed up local development.

Key features

1: Libraries for popular programming languages’ SDKs: Language-specific Cloud Client Libraries from the Cloud SDK support each language’s built-in standards and styles. You may now communicate with Google Cloud APIs more easily in the language of your choosing. Additionally, client libraries take care of authentication, minimize the amount of boilerplate code required, and offer auxiliary methods for huge dataset pagination and asynchronous handling of lengthy tasks.

2: Command Line Interface for Google Cloud (gcloud CLI): The gcloud CLI controls interfaces with Google Cloud resources generally as well as authentication, local settings, developer workflow, and so on. The Google Cloud CLI makes it simple to carry out a variety of basic cloud activities, such as setting up a Compute Engine VM instance, controlling a Google Kubernetes Engine cluster, and deploying an App Engine application, either directly from the command line or through scripts and other automation.

Installation Requirements

  1. Ubuntu 20.04 or higher
  2. A Linux system that has root privileges

There are a number of approaches that can be used to accomplish this

Approach 1: Using a repository to install

Step 1: Add Google Cloud Repository on Ubuntu Linux

To start, check that your system repository has been updated. To add the CA and GNU Privacy Guard to your machine, use the following command.

sudo apt update
sudo apt install apt-transport-https ca-certificates gnupg

Please see the below output

root@ubuntu:/home/rdgmh# sudo apt install apt-transport-https ca-certificates gnupg
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gnupg is already the newest version (2.2.19-3ubuntu2.1).
gnupg set to manually installed.
The following NEW packages will be installed:
  apt-transport-https
The following packages will be upgraded:
  ca-certificates
1 upgraded, 1 newly installed, 0 to remove and 330 not upgraded.
Need to get 145 kB of archives.
After this operation, 156 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 ca-certificates all 20211016~20.04.1 [144 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.9 [1,704 B]
Fetched 145 kB in 6s (23.9 kB/s)                                               
Preconfiguring packages ...
(Reading database ... 182572 files and directories currently installed.)
Preparing to unpack .../ca-certificates_20211016~20.04.1_all.deb ...
Unpacking ca-certificates (20211016~20.04.1) over (20210119~20.04.1) ...
Selecting previously unselected package apt-transport-https.
Preparing to unpack .../apt-transport-https_2.0.9_all.deb ...
Unpacking apt-transport-https (2.0.9) ...
Setting up apt-transport-https (2.0.9) ...
Setting up ca-certificates (20211016~20.04.1) ...
Updating certificates in /etc/ssl/certs...
rehash: warning: skipping ca-certificates.crt,it does not contain exactly one ce
rtificate or CRL
7 added, 9 removed; done.
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for ca-certificates (20211016~20.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@ubuntu:/home/rdgmh# 

You may now use the curl command shown below to add the GPG key from the system’s Google Cloud repository after installing the CA-certificate to your Ubuntu system.

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
root@ubuntu:/home/rdgmh# curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2537  100  2537    0     0   2098      0  0:00:01  0:00:01 --:--:--  2098
OK
root@ubuntu:/home/rdgmh# 

We must now include a private package repository within the system. The repository may be added by using the following echo command in your terminal shell.

echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Step 2: Install Google Software Development Kit

The GNU privacy guard and the Google cloud SDK repositories have been added to our Ubuntu system so far. Once updated, load the updated SDK repository files from the system repository.

sudo apt update

To install the SDK on your Ubuntu Linux machine, perform the following aptitude command, which is provided below. A few PHP modules, the MySQL library, Java, and Google Cloud SDK files will be installed on your drive by the command.

sudo apt install google-cloud-sdk
apt-method
apt method

Method 2: Install GCP SDK with Snap

We may install Google Cloud SDK on our system using the Snap command as it is one of the widely used methods for installing packages on Debian-based systems. Make sure the Snap daemon is installed on your Linux system before executing a Snap command in your terminal shell. Run the following instructions to install it on your machine.

sudo apt update
sudo apt install snapd

The Google Cloud SDK may then be installed on your Linux machine by running the following Snap command, which is shown below. The program will access the official Linux repository, get the stable version of SDK, and install it. You may monitor the SDK’s system-wide installation progress in the terminal window.

sudo snap install google-cloud-sdk --classic
google-cloud-sdk
gcp sdk installed

Start using the Google Cloud SDK

You may access your Google cloud SDK account using a web browser if you already have one by logging in with your Gmail account. Nevertheless, since we are attempting to access the Google Cloud SDK through the CLI, we may launch an SDK login session using the terminal shell by executing the gcloud command.

sudo gcloud init

The command mentioned will assess your internet connectivity and start a login session for the SDK account.

network
init
gcloud init --console-only

Run the command above on your Linux system’s terminal shell if you wish to launch the Google Cloud SDK console view. When the network check is complete, a URL will be provided for you to view in a web browser.

Summary

For folks like me, moving PCs is time-consuming and challenging. Google Cloud offers a cloud-based ready-to-go integrated system that can be a convenient answer. I’ve discussed two alternative ways to install the Google Cloud SDK on a Linux machine and how to use it throughout the whole post.

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x