{"id":6580,"date":"2026-10-07T11:31:12","date_gmt":"2026-10-07T11:31:12","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=6580"},"modified":"2026-10-08T15:39:40","modified_gmt":"2026-10-08T15:39:40","slug":"codes-to-work-with-google-cloud-sdk","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/","title":{"rendered":"Codes to work with Google Cloud SDK"},"content":{"rendered":"\r\n<h1>gcloud Commands for Working With Google Cloud<\/h1>\r\n<p class=\"wp-block-paragraph\"><strong><b>gcloud<\/b><\/strong>\u00a0is the command line tool for Google Cloud, part of the Google Cloud CLI that used to be called the Cloud SDK. Anything you can do by clicking in the console, you can also do by typing a command, and a typed command can be repeated, saved in a script, and shared with a teammate in a way that a sequence of clicks cannot.<\/p>\r\n<p>Commands follow a pattern. They start with gcloud, then a product, then the thing you are working with, then an action, and they finish with a name and any options. In gcloud compute instances list, compute is the product, instances is the resource, and list is the action. Once you see that pattern, you can guess many commands and look up the rest with the help flag.<\/p>\r\n<p>This is a working reference. It covers the commands for VMs, setting up gcloud, managing components, projects, and listing zones, regions, machine types, images, and accounts, with the screenshots from the original page in their original order.<\/p>\r\n<p><strong>Prerequisites:<\/strong><\/p>\r\n<ul>\r\n<li>A Google Cloud account.<\/li>\r\n<li>The Google Cloud CLI installed on your computer, or Cloud Shell open in the console. The Cloud SDK Installation guide in this series covers installing it on Windows.<\/li>\r\n<\/ul>\r\n<h2>Commands for Working With VMs<\/h2>\r\n<h3>List Your VMs<\/h3>\r\n<p>gcloud compute instances list<\/p>\r\n<p>Lists the VM instances in your current project.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6657\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg\" alt=\"\" width=\"857\" height=\"192\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg 922w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19-300x67.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19-768x172.jpg 768w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Start a VM<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute instances start INSTANCE_NAME &#8211;zone=ZONE<\/p>\r\n<p>Starts a stopped VM.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6583\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/10-1-1024x257.jpg\" alt=\"\" width=\"834\" height=\"209\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/10-1-1024x257.jpg 1024w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/10-1-300x75.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/10-1-768x193.jpg 768w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/10-1.jpg 1098w\" sizes=\"auto, (max-width: 834px) 100vw, 834px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Stop a VM<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute instances stop INSTANCE_NAME &#8211;zone=ZONE<\/p>\r\n<p>Stops a running VM. A stopped VM generally stops billing for its compute, but its disks and any reserved addresses still cost money.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6584\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/11-2-1024x186.jpg\" alt=\"\" width=\"924\" height=\"168\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/11-2-1024x186.jpg 1024w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/11-2-300x55.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/11-2-768x140.jpg 768w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/11-2.jpg 1105w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Delete a VM<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute instances delete INSTANCE_NAME &#8211;zone=ZONE<\/p>\r\n<p>Deletes the VM, and gcloud asks you to confirm with y. Be careful here. A VM&#8217;s boot disk is deleted along with it by default, and deleting cannot be undone, so check the name and the zone before you confirm.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6585\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/12-3-1024x293.jpg\" alt=\"\" width=\"937\" height=\"267\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/12-3-1024x293.jpg 1024w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/12-3-300x86.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/12-3-768x220.jpg 768w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/12-3.jpg 1104w\" sizes=\"auto, (max-width: 937px) 100vw, 937px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Create a VM<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute instances create INSTANCE_NAME &#8211;zone=ZONE &#8211;machine-type=MACHINE_TYPE &#8211;boot-disk-size=DISK_SIZE<\/p>\r\n<p>A filled in example looks like this, with the flag name, an equals sign, and the value, and no spaces:<\/p>\r\n<p>gcloud compute instances create my-vm &#8211;zone=us-central1-a &#8211;machine-type=e2-medium &#8211;boot-disk-size=20GB<\/p>\r\n<p>The original page wrote the flags with an en dash and spaces after the equals signs, which makes the command fail. If you leave out the zone, gcloud asks you to choose one from a numbered list, as the next screenshot shows.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6586\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/13-2-1024x292.jpg\" alt=\"\" width=\"1077\" height=\"307\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/13-2-1024x292.jpg 1024w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/13-2-300x86.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/13-2-768x219.jpg 768w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/13-2.jpg 1140w\" sizes=\"auto, (max-width: 1077px) 100vw, 1077px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Choose the zone which you want by specifying the respective number, and press enter.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6587\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/14-2-1024x403.jpg\" alt=\"\" width=\"898\" height=\"353\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/14-2-1024x403.jpg 1024w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/14-2-300x118.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/14-2-768x302.jpg 768w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/14-2.jpg 1152w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2>Setting Up gcloud<\/h2>\r\n<h3>Initialize gcloud<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud init<\/p>\r\n<p>Walks you through signing in and choosing your defaults.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6588\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/15-3.jpg\" alt=\"\" width=\"751\" height=\"589\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/15-3.jpg 885w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/15-3-300x236.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/15-3-768x603.jpg 768w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Choose the project you want to work with by typing its number. You can also create a new project here. Then choose the region and zone, typing y to set a new default or n to keep the current one.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6589\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/16-2.jpg\" alt=\"\" width=\"731\" height=\"527\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/16-2.jpg 893w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/16-2-300x217.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/16-2-768x555.jpg 768w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">You can change defaults later without running the whole setup again, for example to set a default zone, and to see what is currently set:<\/p>\r\n<p>gcloud config set compute\/zone ZONE<br \/>gcloud config list<\/p>\r\n<h2>Managing gcloud Components<\/h2>\r\n<p>Components are the installable parts of the Google Cloud CLI. One important limit applies to all four commands in this section. Google says the component manager is disabled when gcloud was installed with a package manager such as APT or yum, so these commands will not work on that kind of install. Install extra components with the same package manager instead.<\/p>\r\n<h3>List Components<\/h3>\r\n<p>gcloud components list<\/p>\r\n<p>Shows which components are installed and which are not.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6590\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-5-1024x372.jpg\" alt=\"\" width=\"831\" height=\"301\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-5-1024x372.jpg 1024w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-5-300x109.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-5-768x279.jpg 768w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-5.jpg 1162w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Install a Component<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud components install COMPONENT_ID<\/p>\r\n<p>Installs a component. On a system wide install, you need administrator access to install or remove components.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"983\" height=\"855\" class=\"wp-image-6591\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/20.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/20.jpg 983w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/20-300x261.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/20-768x668.jpg 768w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">A command window shows the installation. Press y to confirm.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6593\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/17-2.jpg\" alt=\"\" width=\"682\" height=\"674\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/17-2.jpg 809w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/17-2-300x297.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/17-2-768x759.jpg 768w\" sizes=\"auto, (max-width: 682px) 100vw, 682px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Remove a Component<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud components remove COMPONENT_ID<\/p>\r\n<p>Removes a component. Check the ID first, since other commands may depend on it. A command window opens, and you press y to confirm.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6594\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/18.jpg\" alt=\"\" width=\"720\" height=\"620\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/18.jpg 861w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/18-300x259.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/18-768x662.jpg 768w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Update Components<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud components update<\/p>\r\n<p>Updates your installed components. When asked, press y.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6596\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-6.jpg\" alt=\"\" width=\"744\" height=\"518\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-6.jpg 808w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-6-300x209.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-6-768x535.jpg 768w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2>Working With Projects<\/h2>\r\n<h3>List Projects<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud projects list<\/p>\r\n<p>Shows the projects you have access to.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6597\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/3-6.jpg\" alt=\"\" width=\"585\" height=\"214\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/3-6.jpg 679w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/3-6-300x110.jpg 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Set the Project You Are Working In<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud config set project PROJECT_ID<\/p>\r\n<p>Every later command runs against this project unless you override it.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"826\" height=\"335\" class=\"wp-image-6601\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/4-8.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/4-8.jpg 826w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/4-8-300x122.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/4-8-768x311.jpg 768w\" sizes=\"auto, (max-width: 826px) 100vw, 826px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>Create a Project<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud projects create PROJECT_ID<\/p>\r\n<p>The project ID has to be unique across all of Google Cloud, so no other project anywhere can already use it. It must also follow the ID rules in the Google Cloud Platform and Project Creation guide in this series. Creating a project does not link it to a billing account, so the project cannot use paid resources until you do that. The Enabling Billing guide in this series covers it.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6600\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/21-1.jpg\" alt=\"\" width=\"851\" height=\"204\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/21-1.jpg 1025w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/21-1-300x72.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/21-1-768x184.jpg 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2>Listing Zones, Regions, Machine Types, and Images<\/h2>\r\n<h3>List Zones<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute zones list<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6602\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/5-6.jpg\" alt=\"\" width=\"775\" height=\"344\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/5-6.jpg 885w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/5-6-300x133.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/5-6-768x341.jpg 768w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>List Regions<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute regions list<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6603\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/6-6.jpg\" alt=\"\" width=\"731\" height=\"451\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/6-6.jpg 933w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/6-6-300x186.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/6-6-768x475.jpg 768w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>List Machine Types<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute machine-types list<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6648\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/7-5.jpg\" alt=\"\" width=\"728\" height=\"413\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/7-5.jpg 868w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/7-5-300x170.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/7-5-768x436.jpg 768w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h3>List Images<\/h3>\r\n<p class=\"wp-block-paragraph\">gcloud compute images list<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6669\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/8-6.jpg\" alt=\"\" width=\"800\" height=\"162\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/8-6.jpg 977w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/8-6-300x61.jpg 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/8-6-768x156.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">These listings can run to hundreds of lines. Google&#8217;s gcloud cheat sheet points out that you can narrow any list with the filter, format, limit, and sort flags. For example, this lists VMs whose zone starts with us and which are not the f1 micro machine type:<\/p>\r\n<p>gcloud compute instances list &#8211;filter=&#8221;zone ~ ^us AND -machineType:f1-micro&#8221;<\/p>\r\n<h2>Checking Which Account You Are Using<\/h2>\r\n<p>gcloud auth list<\/p>\r\n<p>Lists the accounts gcloud is signed in with, and marks the active one. It is worth running before any destructive command, so you know which account and project you are about to change.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6653\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/9-2.jpg\" alt=\"\" width=\"677\" height=\"273\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/9-2.jpg 646w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/9-2-300x121.jpg 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/figure>\r\n<h2>Getting Help and Where to Go Next<\/h2>\r\n<p>Add the help flag to any command to see its options, for example gcloud compute instances create with the help flag. For Cloud Storage, the gcloud storage commands are the current route. The Bucket Object Versioning and Object Holds guide in this series explains why gsutil is being phased out of the default installation. The Creating an Instance Using Cloud Shell guide in this series goes further on creating VMs.<\/p>\r\n<h2>Common Mistakes to Avoid<\/h2>\r\n<ul>\r\n<li>Writing flags with an en dash or with a space after the equals sign. Use two real hyphens, and no spaces around the equals sign.<\/li>\r\n<li>Running delete or remove commands without checking the account, project, and zone first.<\/li>\r\n<li>Using gcloud components on an APT or yum install, where the component manager is disabled.<\/li>\r\n<li>Assuming a new project can create resources straight away. It needs a billing account linked first.<\/li>\r\n<li>Leaving out the zone and then answering the interactive prompt wrongly. State the zone in the command.<\/li>\r\n<\/ul>\r\n<p>That covers the everyday gcloud commands for VMs, projects, and components, with the broken ones fixed. To go further, explore <a href=\"https:\/\/prwatech.in\/gcp-training-institutes-in-bangalore\/\">Prwatech&#8217;s Google Cloud training\u00a0program<\/a>, which includes placement assistance.<\/p>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>gcloud Commands for Working With Google Cloud gcloud\u00a0is the command line tool for Google Cloud, part of the Google Cloud CLI that used to be called the Cloud SDK. Anything you can do by clicking in the console, you can also do by typing a command, and a typed command can be repeated, saved in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,1629],"tags":[619,734,605,699,700,704,685,611,703,731,730],"class_list":["post-6580","post","type-post","status-publish","format-standard","hentry","category-google-cloud-platform","category-instance","tag-codes-in-gcp","tag-components-in-gcp","tag-gcp","tag-gcp-certification","tag-gcp-cloud-console","tag-gcp-cloud-sdk","tag-google-cloud-courses","tag-google-cloud-platform","tag-google-cloud-sdk","tag-project-in-gcp","tag-zones-in-gcp"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>gcloud Commands for GCP: A Practical Cheat Sheet PrwaTech<\/title>\n<meta name=\"description\" content=\"A gcloud cheat sheet for VMs, projects, components, and listings, with the broken create command fixed and the risky commands flagged.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"gcloud Commands for GCP: A Practical Cheat Sheet PrwaTech\" \/>\n<meta property=\"og:description\" content=\"A gcloud cheat sheet for VMs, projects, components, and listings, with the broken create command fixed and the risky commands flagged.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-07T11:31:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-08T15:39:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"922\" \/>\n\t<meta property=\"og:image:height\" content=\"207\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/\",\"url\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/\",\"name\":\"gcloud Commands for GCP: A Practical Cheat Sheet PrwaTech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg\",\"datePublished\":\"2026-10-07T11:31:12+00:00\",\"dateModified\":\"2026-10-08T15:39:40+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"A gcloud cheat sheet for VMs, projects, components, and listings, with the broken create command fixed and the risky commands flagged.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg\",\"width\":922,\"height\":207},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Codes to work with Google Cloud SDK\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"gcloud Commands for GCP: A Practical Cheat Sheet PrwaTech","description":"A gcloud cheat sheet for VMs, projects, components, and listings, with the broken create command fixed and the risky commands flagged.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/","og_locale":"en_US","og_type":"article","og_title":"gcloud Commands for GCP: A Practical Cheat Sheet PrwaTech","og_description":"A gcloud cheat sheet for VMs, projects, components, and listings, with the broken create command fixed and the risky commands flagged.","og_url":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-10-07T11:31:12+00:00","article_modified_time":"2026-10-08T15:39:40+00:00","og_image":[{"width":922,"height":207,"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg","type":"image\/jpeg"}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/","url":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/","name":"gcloud Commands for GCP: A Practical Cheat Sheet PrwaTech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg","datePublished":"2026-10-07T11:31:12+00:00","dateModified":"2026-10-08T15:39:40+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"A gcloud cheat sheet for VMs, projects, components, and listings, with the broken create command fixed and the risky commands flagged.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/19.jpg","width":922,"height":207},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/instance\/codes-to-work-with-google-cloud-sdk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Codes to work with Google Cloud SDK"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/6580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=6580"}],"version-history":[{"count":16,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/6580\/revisions"}],"predecessor-version":[{"id":11915,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/6580\/revisions\/11915"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=6580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=6580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=6580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}