0% found this document useful (0 votes)
27 views2 pages

Basic GCloud Commands

Uploaded by

manogara05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Basic GCloud Commands

Uploaded by

manogara05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic GCloud Commands

To check instance or vm status :

sudo gcloud compute instances list | grep -i <server name>

or

sudo gcloud compute instances describe vlgcisoa --format="yaml(name,status,zone)"

To list the VM’s in particular zone

sudo gcloud compute instances list | grep -i <zone>

To Power On the instance or vm:

sudo gcloud compute instances start <server_name>

To Power Off the instance or vm

sudo gcloud compute instances stop <server name>

To Restart/Reboot the instance/vm:


sudo gcloud compute instances reset <Server Name>

To list the attached disks of vm :

sudo gcloud compute instances describe vlgcisoa --format=json | grep -i source | cut -d '/' -f 11 | cut -d
'"' -f 1

or

sudo gcloud compute instances describe vlgcierx --format=flattened | grep -i source | cut -d '/' -f 11

To detach disk from vm :

sudo gcloud compute instances detach-disk <servername> --disk= <diskname>

Note : VM Should be in stop state to detach boot disk

To attach a disk to vm :

This will attach disk as a data disk

sudo gcloud compute instances attach-disk <servername> --disk= <diskname>

This will attach disk as a boot disk

sudo gcloud compute instances attach-disk <servername> --disk= <diskname> --boot


To extend the disk :

sudo gcloud compute disks resize <name_of_the_disk> --size=<Required size in GB> --zone=<zone>

To check machine images

sudo gcloud compute machine-images list | grep -i <server_name >

To check snapshot

sudo gcloud compute snapshots list | grep -i <disk_name >

To Check network tags of VM

sudo gcloud compute instances list --format="table(name,status,tags.list())" | grep -i <server_name>

To add network tags to VM

sudo gcloud compute instances add-tags <Server_Name> --tags=<tag1>,<tag2>, <tag3>

To Remove network tags from VM

sudo gcloud compute instances remove-tags <Server_Name> --tags=<tag_1>,<tag_2>

To Set service account to VM


sudo gcloud compute instances set-service-account <server name> --service-
account <account_name>

You might also like