The previous articles explained how to install gcloud on Ubuntu/Debian distros and RockyLinux/AlmaLinux/CentOS distros. This article will explain how to install gcloud on Linux.
Problem
How to install gcloud on a Linux server?
Solution
If you use Linux other than the Ubuntu/Debian distro and the RockyLinux/AlmaLinux/CentOS distro, and you want to install gcloud on your Linux distro, then below are the steps (I use OpenSUSE 15 distro):
A. Install gcloud
As far as I know, there are 2 methods for installing on a Linux server, and both methods recommend using a user other than root.
1. Use the script
Before you install gcloud using the script, make sure there are tar and curl packages, and Python version 3.8 and up on your server. You can check it with the following command:
python3 --version
After that, use the following command to download and install the script:
curl https://sdk.cloud.google.com | bash
Then you will see a display like the one below:

Wait until it’s finished, and you will see a display like the one below:

From the image above, you are asked to create a new SSH connection so that the effect can be seen, and type the command below:
./google-cloud-sdk/bin/gcloud version

If you want to type the gcloud command without having to type ./google-cloud-sdk/bin/gcloud, then run the command below:
echo "alias gcloud=./google-cloud-sdk/bin/gcloud" >> ~/.bashrc
source ~/.bashrc

2. Using the installer
Run the following commands to install gcloud on your Linux server:
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz
tar -xf google-cloud-cli-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
After installation completes, use the following command to test the gcloud command:
./google-cloud-sdk/bin/gcloud version
B. Connect to GCP
After you install gcloud on your server, type the command below:
gcloud init
Then there will be a display like the image below:

Click the Ctrl+Click button in the red box to open the link in a browser, or if you have difficulty, copy what is in the red box and place it in your browser so you will see a display like the one below:

Click on the Google account that will access GCP, then there will be a display like the image below:

Click the Continue button, then the display below will appear:

Click the Allow button, then the display below will appear:

Click the Copy button, and paste it into the CLI on your server as in the image below:

Select the project and configure the zone as in the image above. After that, the gcloud configuration is complete.
C. Test gcloud
Now, try gcloud to access your GCP. I try to list my virtual machine in GCP using the below command:
gcloud compute instances list
Then the display below will appear:

If you get a display like the one above, you have successfully used gcloud to access your GCP.
Note
If you have many projects on your GCP, you can choose one of these projects as the starting point for your gcloud on GCP. You can switch projects using the command:
gcloud config set project PROJECT_ID
Change PROJECT_ID to the project ID you want to switch to.
References
cloud.google.com
liquidweb.com
bacancytechnology.com

