DevOps | Cloud | Analytics | Open Source | Programming





GCP Google Cloud CLI - gcloud commands



The GCP Google Cloud CLI - gcloud commands or gcloud cli or command-line tool is used to create and manage various Google cloud components.

(We Keep Updating this Cheatsheet - So Bookmark this Page) If you haven't set up google cloud sdk in your local machine , you can refer our post which explains how to do it here - How To Install Google Cloud GCP Command Line Utility gcloud ?  

Authorize access and Google Cloud SDK setup steps:

This command will initialize, authorize, and configure the gcloud tool in your local machine or laptop.


gcloud init

Welcome! This command will take you through the configuration of gcloud.

This command lists all The Projects and provides option

    • to change current project settings
    • add a new project configuration
    • switch project configurations
You can pick from the below config options -

  • Re-initialize this configuration [esqimo-preprod] with new settings
  • Create a new configuration
  • Switch to and re-initialize existing configuration: [default]
  • Switch to and re-initialize existing configuration: [project 1]
  • Switch to and re-initialize existing configuration: [project 2]
Choose the option to login and select in case you have multiple google accounts. On a broader level, gcloud does the below step by step -

  • Select configuration
  • Set up credentials
  • Set project
  • (Optional) Set default GCE zone (Compute API must be enabled)
  • (Optional) Set default GCE region (Compute API must be enabled)
  • (Optional) Create default config file for gsutil

Activate Authorization


    gcloud auth activate-service-account --key-file <YOUR\_KEY\_FILE>

Display version


gcloud version

Where is gcloud in PATH


$ which gcloud
/usr/bin/gcloud

Where Google Cloud SDK is installed


$ gcloud info --format="value(installation.sdk\_root)"


dirname $(which gcloud)


ls $(dirname $(which gcloud))

gcloud Default Configuration folders

Default Configs


~/.config/gcloud/configurations/config\_default

New Configs


~/.config/gcloud/configurations/<NEw\_config\_Name>

Disable\Ignore\Hide all terminal interactive prompts

Use option --quiet or -q to disable all interactive prompts


gcloud -q compute instances

Display all the properties for the current configuration.


gcloud config list

Display a list of all available configurations.


gcloud config configurations list

Activate a configuration to Switch accounts


gcloud config configurations activate <config\_name>

Create a configuration


gcloud config configurations create <New\_Config\_Name>

Created \[New\_Config\_Name\].
Activated \[New\_Config\_Name\].

List all credentialed accounts


gcloud auth list

Auth Login


gcloud auth login

Remove access credentials for an account.


gcloud auth revoke

What config is used by gcloud (by default):


$ gcloud config list

Application default Login credentials


gcloud auth application-default login

To Get the Organizaton ID


gcloud organizations list

List all the roles associated with a gcp service account


gcloud projects get-iam-policy <PROJECT\_ID>

  • The IAM policies for the project lets you setup who can perform specific actions on a specific resource in the project.
  • The IAM policies for service accounts lets you to control the ownership , access to the service accounts and their settings.
  If you want to prints the output as json format


$ gcloud projects get-iam-policy <PROJECT\_ID> --format=json

List all IAM users for my Google Cloud Project


$ gcloud iam service-accounts list

Add user to a role


$ gcloud projects add-iam-policy-binding \[project\_id\] \\
--member="user:<SOME\_EMAIL>" \\
--role="roles/iam.serviceAccountUser"

Add a google-group to a role


$ gcloud projects add-iam-policy-binding \[project\_id\] \\
--member="group:group\[email protected]" \\
--role="roles/storage.admin"

Remove user from a role


$ gcloud projects remove-iam-policy-binding \[project\_id\] \\
--member="user:<SOME\_EMAIL>" \\
--role="roles/iam.serviceAccountUser"

Change to the account associated with the project


gcloud config set account <Your\_Account>

Install components


gcloud components install

List components


$ gcloud components list

Your current Cloud SDK version is: xxxx.x.x
The latest available version is: xxx.x.x


 Components │
├───────────────┬──────────────────────────────────┬───────────────┬──────────┤
│ Status        │         Name                     │ ID            │ Size     │
├───────────────┼──────────────────────────────────┼───────────────┼──────────┤
│ Not Installed │ App Engine Go Extensions         │ app-engine-go │ 47.9 MiB │
│ Not Installed │ Bigtable Command Line Tool       │ cbt           │ 3.8 MiB  │
│ Not Installed │ Cloud Datalab Command Line Tool  │ datalab       │ < 1 MiB  │

SSH into a VM instance 


gcloud compute ssh

Configure SSH configuration files


gcloud compute config-ssh

List instances


gcloud compute instances list

List instances in a zone


gcloud compute instances list --filter="zone:<ZONE\_NAME>"  (e.g. ZONE\_NAME=us-central-a)

List projects


gcloud projects list

List project Info


gcloud compute project-info describe

List Instance


gcloud compute instances list

List your project's logs


gcloud logging logs list

Change the project in GCP using CLI commands


gcloud config set project <project\_id>

Alternatively set the environment variable - $CLOUDSDK_CORE_PROJECT  

List the project names


gcloud projects list

Current Active Project


gcloud config get-value project

Copy a directory from a Google Compute instance to local machine


gcloud compute scp --recurse <user\_name>@instance\_name:./\* "local\_dir"

e.g.


gcloud compute scp --recurse <gcp\_vm> ./\* <local\_dir>

Find Docker Credentials


$ which docker-credential-gcloud
/Users/xxxxxx/google-cloud-sdk/bin/docker-credential-gcloud

Other Interesting Reads :


gcloud command ,gcloud command not found ,gcloud commands ,gcloud commands cheat sheet ,gcloud command to list compute instances ,gcloud command not found in mac ,gcloud command to set project ,gcloud command to create kubernetes cluster ,gcloud command to create virtual network ,gcloud command app ,gcloud auth command ,gcloud alpha command ,gcloud app engine command ,gcloud app engine command line ,gcloud run command as service account ,gcloud enable api command line ,gcloud command to create a cluster ,gcloud bq command ,cloud backups command ,gcloud beta commands ,gcloud basic commands ,gcloud beta commands install ,gcloud bigtable commands ,gcloud create bucket command line ,gcloud command to list buckets ,gcloud command cheat sheet ,gcloud command change project ,gcloud command console ,gcloud command connect ,gcloud command check ,gcloud command cache ,gcloud commands cheat sheet pdf ,gcloud commands container ,gcloud command deploy the application in the app engine ,gcloud command download ,gcloud command documentation ,gcloud command dataproc ,gcloud command describe ,gcloud command delete ,gcloud deploy command ,gcloud dataflow command ,gcloud command examples ,gcloud command exit code ,gcloud command editor ,gcloud command exit ,gcloud execute command ,gcloud command to enable api ,gcloud scp command example ,gcloud app estimate command ,gcloud command format ,gcloud command for dataflow ,gcloud command firebase ,gcloud commands for iam roles ,gcloud firestore command ,gcloud command not found windows ,gcloud command not found mac os ,gcloud commands google ,gcloud get command ,gcloud gke commands ,gcloud command to get service account ,google gcloud command not found ,gcloud command hangs ,gcloud command help ,gcloud command install ,gcloud command in python ,gcloud command image ,gcloud command init ,gcloud command instance ,gcloud command in linux ,gcloud command info ,gcloud command interface ,gcloud command not found jenkins ,gcloud kubectl command not found ,gcloud kubernetes commands ,gcloud kms commands ,gcloud command line ,gcloud command line windows ,gcloud command line cheat sheet ,gcloud command line install ,gcloud command list ,gcloud command line login ,gcloud command list compute instances ,gcloud command line change project ,gcloud command mac ,gcloud ml command ,gcloud monitoring commands ,gcloud command not found mac ,gcloud deployment manager command ,gcloud command not found ubuntu ,gcloud command not found brew ,gcloud command not working ,gcloud command not found bash ,gcloud command options ,gcloud command osx ,gcloud organizations command ,gcloud run command on instance ,gcloud command line output ,gcloud command python ,gcloud command prompt ,gcloud command proxy ,gcloud command pubsub ,gcloud command publish ,gcloud python2 command not found ,gcloud project command ,gcloud command query ,gcloud command reference ,gcloud command run ,gcloud command reset ,gcloud command line reference ,gcloud command to set region ,gcloud auth revoke command ,gcloud command syntax ,gcloud command set project ,gcloud command service account ,gcloud command slow ,gcloud command script ,gcloud command ssh ,gcloud command sdk ,gcloud command start ,gcloud command to list projects ,gcloud command to create vm ,gcloud command to create instance ,gcloud command to create bucket ,gcloud command update ,gcloud command line ubuntu ,gcloud command line utility ,gcloud command is used to list all deployments ,gcloud container update command ,gcloud command verbose ,gcloud command version ,gcloud vpc commands ,gcloud command to create vm instance ,gcloud command to list vms ,gcloud command to connect to vm ,gcloud command to stop a vm ,gcloud command windows ,gcloud command will show images ,gcloud command wait ,gcloud command ,gcloud zone command ,gcloud command to set zone ,zsh gcloud command not found ,gcloud command not found after install ,command 'gcloud' not found but can be installed with ,bash gcloud command not found windows ,gcloud command not found install ,gcloud init command not found ,gcloud init command not found ubuntu ,gcloud command not found linux ,gcloud command not found on mac ,sudo gcloud command not found ,gcloud command not found zsh ,gcloud commands in python ,gcloud commands linux ,gcloud commands instances ,gcloud commands example ,gcloud alpha commands ,gcloud app engine commands ,gcloud bigquery commands ,gcloud compute commands ,gcloud dataflow commands ,gcloud firestore commands ,gcloud commands from command ,google cloud gcloud commands ,gcloud commands list ,all gcloud commands ,google cloud commands ,gcloud command line mac ,gcloud command line tutorial ,gcloud commands run ,gcloud command sql ,gcloud command to change project ,gcloud update command ,gcloud cli commands ,google cloud commands cheat sheet ,gcp commands cheat sheet ,gcp command line cheat sheet ,what is the gcloud command to list compute instances quizlet ,what is the gcloud command to list compute instances ,gcloud list compute instances ,gcloud instance list ,question 2 what is the gcloud command to list compute instances ,gcloud config set project project\_id ,gcloud set project id command ,gcloud shell command to create kubernetes cluster ,which sub command of cloud is used to create kubernetes cluster ,gcloud command to create cluster ,gcloud create kubernetes cluster ,how to create kubernetes cluster in gcp ,gcloud cluster create ,gcloud command line tool download ,gcloud app deploy command ,gcloud app engine deploy command ,restarting command $ gcloud components install app-engine-java ,gcloud app instances command ,gcloud apk ,gcloud app logs command ,gcloud command ,gcloud command not found ,gcloud commands ,gcloud commands cheat sheet ,gcloud command to list compute instances ,gcloud command not found in mac ,gcloud command to set project ,gcloud command to create kubernetes cluster ,gcloud command to create virtual network ,gcloud command app ,gcloud auth command ,gcloud alpha command ,gcloud app engine command ,gcloud app engine command line ,gcloud run command as service account ,gcloud enable api command line ,gcloud command to create a cluster ,gcloud bq command ,cloud backups command ,gcloud beta commands ,gcloud basic commands ,gcloud beta commands install ,gcloud bigtable commands ,gcloud create bucket command line ,gcloud command to list buckets ,gcloud command cheat sheet ,gcloud command change project ,gcloud command console ,gcloud command connect ,gcloud command check ,gcloud command cache ,gcloud commands cheat sheet pdf ,gcloud commands container ,gcloud command deploy the application in the app engine ,gcloud command download ,gcloud command documentation ,gcloud command dataproc ,gcloud command describe ,gcloud command delete ,gcloud deploy command ,gcloud dataflow command ,gcloud command examples ,gcloud command exit code ,gcloud command editor ,gcloud command exit ,gcloud execute command ,gcloud command to enable api ,gcloud scp command example ,gcloud app estimate command ,gcloud command format ,gcloud command for dataflow ,gcloud command firebase ,gcloud commands for iam roles ,gcloud firestore command ,gcloud command not found windows ,gcloud command not found mac os ,gcloud commands google ,gcloud get command ,gcloud gke commands ,gcloud command to get service account ,google gcloud command not found ,gcloud command hangs ,gcloud command help ,gcloud command install ,gcloud command in python ,gcloud command image ,gcloud command init ,gcloud command instance ,gcloud command in linux ,gcloud command info ,gcloud command interface ,gcloud command not found jenkins ,gcloud kubectl command not found ,gcloud kubernetes commands ,gcloud kms commands ,gcloud command line ,gcloud command line windows ,gcloud command line cheat sheet ,gcloud command line install ,gcloud command list ,gcloud command line login ,gcloud command list compute instances ,gcloud command line change project ,gcloud command mac ,gcloud ml command ,gcloud monitoring commands ,gcloud command not found mac ,gcloud deployment manager command ,gcloud command not found ubuntu ,gcloud command not found brew ,gcloud command not working ,gcloud command not found bash ,gcloud command options ,gcloud command osx ,gcloud organizations command ,gcloud run command on instance ,gcloud command line output ,gcloud command python ,gcloud command prompt ,gcloud command proxy ,gcloud command pubsub ,gcloud command publish ,gcloud python2 command not found ,gcloud project command ,gcloud command query ,gcloud command reference ,gcloud command run ,gcloud command reset ,gcloud command line reference ,gcloud command to set region ,gcloud auth revoke command ,gcloud command syntax ,gcloud command set project ,gcloud command service account ,gcloud command slow ,gcloud command script ,gcloud command ssh ,gcloud command sdk ,gcloud command start ,gcloud command to list projects ,gcloud command to create vm ,gcloud command to create instance ,gcloud command to create bucket ,gcloud command update ,gcloud command line ubuntu ,gcloud command line utility ,gcloud command is used to list all deployments ,gcloud container update command ,gcloud command verbose ,gcloud command version ,gcloud vpc commands ,gcloud command to create vm instance ,gcloud command to list vms ,gcloud command to connect to vm ,gcloud command to stop a vm ,gcloud command windows ,gcloud command will show images ,gcloud command wait ,gcloud command ,gcloud zone command ,gcloud command to set zone ,zsh gcloud command not found ,gcloud command not found after install ,command 'gcloud' not found but can be installed with ,bash gcloud command not found windows ,gcloud command not found install ,gcloud init command not found ,gcloud init command not found ubuntu ,gcloud command not found linux ,gcloud command not found on mac ,sudo gcloud command not found ,gcloud command not found zsh ,gcloud commands in python ,gcloud commands linux ,gcloud commands instances ,gcloud commands example ,gcloud alpha commands ,gcloud app engine commands ,gcloud bigquery commands ,gcloud compute commands ,gcloud dataflow commands ,gcloud firestore commands ,gcloud commands from command ,google cloud gcloud commands ,gcloud commands list ,all gcloud commands ,google cloud commands ,gcloud command line mac ,gcloud command line tutorial ,gcloud commands run ,gcloud command sql ,gcloud command to change project ,gcloud update command ,gcloud cli commands ,google cloud commands cheat sheet ,gcp commands cheat sheet ,gcp command line cheat sheet ,what is the gcloud command to list compute instances quizlet ,what is the gcloud command to list compute instances ,gcloud list compute instances ,gcloud instance list ,question 2 what is the gcloud command to list compute instances ,gcloud config set project project\_id ,gcloud set project id command ,gcloud shell command to create kubernetes cluster ,which sub command of cloud is used to create kubernetes cluster ,gcloud command to create cluster ,gcloud create kubernetes cluster ,how to create kubernetes cluster in gcp ,gcloud cluster create ,gcloud command line tool download ,gcloud app deploy command ,gcloud app engine deploy command ,restarting command $ gcloud components install app-engine-java ,gcloud app instances command ,gcloud apk ,gcloud app logs command ,google cloud command ,google cloud commands ,google cloud command line ,google cloud commands cheat sheet ,google cloud command line install ,google cloud command line interface ,google cloud command center ,google cloud command line login ,google cloud security command center api ,google cloud bq command ,access google cloud storage bucket command line ,google cloud console command line ,google cloud command line cheat sheet ,google cloud security command center pricing ,google cloud command line commands ,google cloud deploy command ,google cloud directory sync command line ,google-cloud command not found ,create a google cloud firewall command line ,command for google cloud storage ,google cloud platform gcloud command ,google cloud storage command gsutil ,create a google cloud compute instance command line ,command in google cloud ,google cloud kubernetes commands ,google cloud command line windows ,google cloud shell command list ,google cloud storage command line ,create a google cloud virtual network command line ,google cloud platform command line ,google cloud platform command ,google cloud shell command list pdf ,google cloud platform security command center ,which command shows google cloud project-specific details ,google cloud commands list ,google cloud security command center ,google cloud sdk command line ,google cloud command line tools ,installing google cloud command line utility ,command to create google cloud virtual network ,which command shows google cloud virtual machine instances ,google cloud shell commands ,google cloud bq commands ,google cloud cli commands ,google cloud gcloud commands ,google cloud gsutil commands ,commands in google cloud ,google cloud powershell commands ,google cloud platform commands ,google cloud sdk commands ,google cloud ssh commands ,google cloud storage commands ,google cloud terminal commands ,google cloud sql command line ,create a google cloud subnet command line ,upload file to google cloud storage command line ,setup gcloud ,install google cloud sdk command line ,google cloud cli ,google cloud cli install ,google cloud client ,google cloud cli commands ,google cloud client library python ,google cloud cli sdk ,google cloud client id ,google cloud client vpn ,google cloud cli mac ,google cloud cli authentication ,google cloud api cli ,google cloud cli brew ,google cloud cli change project ,google cloud console cli ,google cloud cli download ,google cloud cli docker ,google cloud cli github ,how to install google cloud cli ,google cloud cli install mac ,google cloud cli instances ,install google cloud cli ubuntu ,what is google cloud cli ,google cloud cli login ,google cloud cli linux ,google cloud clipboard ,google cloud platform cli ,google cloud run cli ,google cloud cli setup ,google cloud storage cli ,google cloud cli tools ,login to google cloud cli ,google cloud cli ubuntu ,google cloud cli windows ,installing google cloud command line utility ,google cloud client windows ,google cloud client side encryption ,google cloud client sdk ,google cloud client authentication ,google cloud client list ,google cloud client api ,google cloud api client python ,google cloud storage client api ,google cloud translation api client library for java ,google.cloud.translate' has no attribute 'client' ,google.cloud.bigquery.client ,google cloud load balancer client certificate ,google cloud storage client credential ,google cloud storage c++ client ,google.cloud.storage.client.client ,google cloud client download ,google cloud datastore client ,google cloud sdk client download ,google cloud storage desktop client ,google cloud datastore python client ,google cloud firestore client ,google cloud client library for python ,google cloud client library for java ,google cloud client libraries for .net ,google cloud storage ftp client ,google cloud client github ,get google cloud storage client ,google cloud http client ,google cloud client install ,imports the google cloud client library ,google cloud java client ,google cloud client library java ,google cloud storage client java ,google-cloud-pubsub java client ,google cloud messaging javascript client ,google cloud client library ,google.cloud.logging.client ,google cloud storage client library ,google cloud storage linux client ,google cloud mysql client ,google cloud storage client mac ,google cloud openvpn client ,google cloud client python ,google cloud platform client id ,google cloud python client library ,google cloud print client ,google cloud pubsub client ,google cloud platform client ,google cloud storage client python ,google cloud bigquery client python ,google cloud client secret ,google cloud storage client ,google cloud sql client ,google cloud storage client windows ,google cloud translate client ,google cloud print windows client ,google cloud commands ,google cloud sdk shell commands ,google cloud gcloud commands ,all gcloud commands ,google cloud storage client library python ,google.cloud module python ,google cloud for python ,google cloud sdk setup ,google-cloud-sdk install ,google cloud sdk installer ,google cloud sdk installation ,google cloud sdk latest version ,