← 返回命令列表

Linux command

gcloud 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Initialize gcloud

gcloud init

Login to Google

gcloud auth login

Set the active project

gcloud config set project [project-id]

List all projects

gcloud projects list

Create a Compute Engine VM

gcloud compute instances create [name] --zone=[zone]

List running VM

gcloud compute instances list

Get application-default

gcloud auth application-default login

Format output as JSON

gcloud compute instances list --format=json

说明

gcloud is the Google Cloud Platform CLI for managing cloud resources. It provides commands for all GCP services including Compute Engine, Kubernetes Engine, Cloud SQL, Cloud Run, Cloud Functions, and more. The tool handles authentication, configuration, and resource management. Commands are organized by service groups with subcommands for specific operations. The --format and --filter flags are available on all commands for scripting and automation. Output formats include json, yaml, csv, table, text, value, and more. Multiple named configurations can be managed with gcloud config configurations for switching between projects and accounts.

参数

auth
Authentication and credential commands.
config
Configuration management.
compute
Compute Engine commands.
container
Kubernetes Engine commands.
projects
Project management.
--project _ID_
Override the default project for this command.
--format _FORMAT_
Output format: json, yaml, csv, table, text, value, etc.
--filter _EXPRESSION_
Filter results (e.g. 'name~prod').
--quiet, -q
Disable interactive prompts and use defaults.
--verbosity _LEVEL_
Logging verbosity: debug, info, warning, error, critical, none.
--account _ACCOUNT_
Override the default account for this command.
--region _REGION_
Override the default region for this command.
--zone _ZONE_
Override the default zone for this command.
--configuration _NAME_
Use a named configuration instead of the active one.
--flags-file _FILE_
Read flags from a YAML or JSON file.
--flatten _KEY_
Flatten nested list or map output.
--help
Display help information.

FAQ

What is the gcloud command used for?

gcloud is the Google Cloud Platform CLI for managing cloud resources. It provides commands for all GCP services including Compute Engine, Kubernetes Engine, Cloud SQL, Cloud Run, Cloud Functions, and more. The tool handles authentication, configuration, and resource management. Commands are organized by service groups with subcommands for specific operations. The --format and --filter flags are available on all commands for scripting and automation. Output formats include json, yaml, csv, table, text, value, and more. Multiple named configurations can be managed with gcloud config configurations for switching between projects and accounts.

How do I run a basic gcloud example?

Run `gcloud init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does auth do in gcloud?

Authentication and credential commands.