Install Multiple Version of Google Cloud SDK (gcloud) in Ubuntu

Apr 21, 2019

Scenario: I already have a version of Google Cloud SDK installed on my machine which I intend to preserve, while installing another newer version of Google Cloud SDK.

Backup Original/Legacy version

The original location of the sdk is at /code/google-cloud-sdk. I rename it as google-cloud-sdk-legacy.

cd /codemv google-cloud-sdk google-cloud-sdk-legacy

There is also a configuration stored at ~/.config/gcloud. I renamed it as gcloud-legacy.

cd ~/.config/cp gcloud gcloud-legacy

Test run gcloud command and it shall not work now.

To run the legacy gcloud, use the following command.

CLOUDSDK_CONFIG=~/.config/gcloud-legacy /code/google-cloud-sdk-legacy/bin/gcloud config list

Install new Google Cloud SDK

Download the latest google-cloud-sdk-VERSION-linux-x86_64.tar.gz.

cd /codewget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-242.0.0-linux-x86_64.tar.gz

Unzip .tar.gz to google-cloud-sdk

tar zxvf google-cloud-sdk-242.0.0-linux-x86_64.tar.gz google-cloud-sdk

Run installation.

./google-cloud-sdk/install.sh

Optional: initialize the SDK

gcloud init

NOTE: If you maintain the existing ~/.config/gcloud directory, then gcloud init is optional.

Check gcloud version.

gcloud version

Check gcloud configuration.

gcloud config list

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.