Linux command
gcloud-compute 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List VM instances
gcloud compute instances list
Create instance
gcloud compute instances create [name] --zone=[zone]
SSH to instance
gcloud compute ssh [instance] --zone=[zone]
Stop instance
gcloud compute instances stop [name] --zone=[zone]
List disks
gcloud compute disks list
说明
gcloud compute is the command-line interface for Google Compute Engine, Google's Infrastructure-as-a-Service offering. It provides complete control over virtual machines, persistent disks, networks, load balancers, and other infrastructure primitives. The instances subcommand handles VM lifecycle operations including creation with customizable machine types, starting and stopping instances, and deletion. Network resources like VPCs, subnets, firewall rules, and routes are managed through their respective subcommands. Special convenience features include built-in SSH access via gcloud compute ssh, which automatically manages SSH keys and connection details, and gcloud compute scp for secure file transfers. The command group supports advanced features like custom images, snapshots, instance groups, and managed instance groups for autoscaling. All operations respect zones and regions, which must be specified either per-command or via configuration defaults.
参数
- --zone _ZONE_
- Compute zone for the resource (e.g. us-central1-a).
- --region _REGION_
- Compute region for regional resources.
- --project _PROJECT_
- Google Cloud project ID to target.
- --format _FORMAT_
- Output format (json, yaml, table, value).
- --filter _EXPR_
- Filter results by expression.
- --help
- Display help information.
FAQ
What is the gcloud-compute command used for?
gcloud compute is the command-line interface for Google Compute Engine, Google's Infrastructure-as-a-Service offering. It provides complete control over virtual machines, persistent disks, networks, load balancers, and other infrastructure primitives. The instances subcommand handles VM lifecycle operations including creation with customizable machine types, starting and stopping instances, and deletion. Network resources like VPCs, subnets, firewall rules, and routes are managed through their respective subcommands. Special convenience features include built-in SSH access via gcloud compute ssh, which automatically manages SSH keys and connection details, and gcloud compute scp for secure file transfers. The command group supports advanced features like custom images, snapshots, instance groups, and managed instance groups for autoscaling. All operations respect zones and regions, which must be specified either per-command or via configuration defaults.
How do I run a basic gcloud-compute example?
Run `gcloud compute instances list` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --zone _ZONE_ do in gcloud-compute?
Compute zone for the resource (e.g. us-central1-a).