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-legacyThere is also a configuration stored at ~/.config/gcloud. I renamed it as gcloud-legacy.
cd ~/.config/cp gcloud gcloud-legacyTest 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 listInstall 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.gzUnzip .tar.gz to google-cloud-sdk
tar zxvf google-cloud-sdk-242.0.0-linux-x86_64.tar.gz google-cloud-sdkRun installation.
./google-cloud-sdk/install.shOptional: initialize the SDK
gcloud initNOTE: If you maintain the existing ~/.config/gcloud directory, then gcloud init is optional.
Check gcloud version.
gcloud versionCheck gcloud configuration.
gcloud config listReferences: