Sunday, November 9, 2025

How to Install Google Cloud SDK & Login to GCP (All Methods) ?

✅ How to Install Google Cloud SDK & Login to GCP (All Methods)


🌟 Step 1 — Install Google Cloud SDK

Windows

Download installer:

https://cloud.google.com/sdk/docs/install

macOS

curl https://sdk.cloud.google.com | bash
exec -l $SHELL

Linux

curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-367.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-sdk-367.0.0-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
exec -l $SHELL

⚙️ Step 2 — Initialize Cloud SDK

gcloud init

🔐 GCP Login Methods

✅ Method 1 — Login Using Browser

gcloud auth login

✅ Method 2 — Login Without Browser (SSH Server)

gcloud auth login --no-launch-browser

You will get a URL → open it → paste code.

✅ Method 3 — Set Default Project

gcloud config set project PROJECT_ID

✅ Method 4 — Verify Login

gcloud config list

🎯 Method 5 — Application Default Credentials (ADC)

Used by SDKs / Terraform / APIs

gcloud auth application-default login

🔐 Method 6 — Service Account Login (Automation / CI-CD)

gcloud auth activate-service-account --key-file=key.json
gcloud config set project PROJECT_ID

🛑 Method 7 — Workload Identity Federation (Keyless Login)

gcloud auth login --cred-file=workload-identity-credential.json

🧠 Method 8 — Cloud Shell Login (No Install)

Go to:

https://console.cloud.google.com

Click Activate Cloud Shell ✅

🧩 Method 9 — Terraform + GCP Authentication

gcloud auth application-default login

🔐 Method 10 — Docker / Artifact Registry Login

gcloud auth configure-docker

💻 Method 11 — Login to GCP Git Repos

gcloud source repos clone REPO_NAME --project=PROJECT_ID

📌 Useful Commands

ActionCommand
List projectsgcloud projects list
Show active authgcloud auth list
Remove logingcloud auth revoke
Update SDKgcloud components update

✨ Mastering Bash Special Characters — The Real Power of Linux Terminal 🔥

🔥 Master Bash Special Characters — Power of Linux Terminal

If you work in Linux, DevOps, Cloud, Cyber Security, or Automation, Bash special characters are your superpower.

These symbols control execution, variables, redirection, scripting logic, and automation. Here is the complete cheat-sheet 👇


✅ Basic Bash Symbols

SymbolMeaningExample
$Variable / Command outputecho $HOME
#Comment# comment
*Wildcard (match all)*.txt
?Match one characterfile?.log
\Escape characterecho \"hello\"
~Home directorycd ~

✅ Command Execution Operators

SymbolMeaningExample
;Run sequentiallycmd1; cmd2
&&Run if previous successbuild && deploy
||Run if previous failscd logs || mkdir logs
&Run in backgroundsleep 5 &

✅ Pipes & Redirection

SymbolMeaningExample
|Pipe outputls | grep txt
>Output to file (overwrite)echo hi > file.txt
>>Append to fileecho hi >> file.txt
<Redirect inputsort < data.txt

✅ Advanced Redirection

SymbolMeaningExample
<<Heredoccat << EOF
<<<Here-stringcat <<< "Hello"

✅ Test & Grouping

SymbolMeaningExample
[ ]Test[ -f file.txt ]
[[ ]]Advanced test[[ $a == $b ]]
( )Subshell(cd /tmp && ls)
{ }Command block{ echo A; echo B; }

✅ Brace Expansion

PatternMeaningExample
{1..5}Number rangeecho {1..5}
{a,b}Listmv f.{txt,backup}

✅ Special Shell Variables

VariableMeaning
$?Last command status
$$Process ID
$!Last background PID
$@All arguments
$#Argument count

🎯 Example Script


#!/bin/bash
if [[ -f "$1" ]]; then
  grep "error" "$1" >> logs.txt && echo "Logged ✅"
else
  echo "File not found ❌" && exit 1
fi

#linux #bash #devops #shellscripting #cloud #sysadmin #automation