使用 Cloud Shell 运行 gcloud
命令
了解如何在 Cloud Shell 中运行 gcloud CLI 命令。
如需遵循有关此任务的分步指导,请直接在 Cloud Shell Editor 中点击操作演示:
准备工作
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
设置 gcloud
属性
- 启动 Cloud Shell Editor。
通过设置核心属性,可防止在向终端输出消息时使用颜色:
gcloud config set disable_color true
取消设置
disable_color
属性:gcloud config unset disable_color
如果您已启用 Compute Engine API,请设置您的首选 Compute Engine 区域。将
REGION
替换为区域名称,例如us-east1
:gcloud config set compute/region REGION
或者,您也可以设置首选区域。 将
ZONE
替换为可用区名称,例如us-east1-b
:gcloud config set compute/zone ZONE
如需了解 Compute Engine 区域和可用区,请参阅区域和可用区。
显示可用属性的列表:
gcloud topic configurations
运行核心命令
列出其凭据存储在本地系统上的账号:
gcloud auth list
gcloud CLI 会显示存储了凭据的账号的列表,其中
ACCOUNT_EMAIL
表示一个或多个有效账号的列表:Credentialed Accounts ACTIVE ACCOUNT \*
ACCOUNT_EMAIL
列出活跃 gcloud CLI 配置中的属性:
gcloud config list
gcloud CLI 会显示类似于以下内容的属性列表,其中
ACCOUNT_EMAIL
和PROJECT_ID
会显示您的电子邮件地址和项目 ID:[core] account = ACCOUNT_EMAIL disable_usage_reporting = False project = PROJECT_ID
查看有关您的 gcloud CLI 安装和活跃配置的信息:
gcloud info
查看有关 gcloud
命令的帮助
查看有关
gcloud compute instances create
命令的帮助:gcloud help compute instances create
查看
gcloud topic
下的可用命令:gcloud help topic
查看有关过滤的信息:
gcloud topic filters
详细了解
gcloud
命令结构:gcloud topic command-conventions