الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

gcloud

The command line of Google Cloud: projects, VMs, GKE clusters, Cloud Run, IAM and more.

المستوى
أداة DevOps
المجموعة
البنية التحتية ككود والسحابة
يحتاج root
لا
الحزمة
google-cloud-cli

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

gcloud works like az and aws: gcloud GROUP COMMAND. Everything belongs to a project; set it once with gcloud config set project. gcloud auth login is for you, service accounts or Workload Identity Federation are for CI (no long-lived keys).

It is part of the Google Cloud CLI, together with gsutil / gcloud storage and bq.

طريقة الكتابة

gcloud GROUP [SUBGROUP] COMMAND [OPTIONS]

الأجزاء الرئيسية

Main groups

auth login / auth list
Log in / show accounts.
config set|list|configurations
Defaults (project, region) and profiles.
projects list
Your projects.
compute instances …
VMs (create, list, ssh, stop).
container clusters …
GKE clusters and their credentials.
run deploy|services
Cloud Run.
storage ls|cp
Cloud Storage buckets.
iam service-accounts / projects add-iam-policy-binding
Identities and roles.
artifacts repositories / docker
Artifact Registry.
logging read
Read logs.

الخيارات 7

الأكثر استخدامًا

Common flags

--project ID
Project for this command.
--region / --zone
Location.
--format json|yaml|table(…)|value(…)
Output format.
--filter EXPR
Filter the list.
--quiet, -q
No questions (scripts).
--impersonate-service-account SA
Act as a service account.
--verbosity debug
More output.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Log in and set the default project

    gcloud auth login
    gcloud config set project acme-shop-prod
    gcloud config set compute/region europe-west4
  2. 2One profile per environment

    gcloud config configurations create dev
    gcloud config configurations activate prod
  3. 3Get kubeconfig for a GKE cluster

    gcloud container clusters get-credentials shop-gke --region europe-west4
    kubectl get nodes
  4. 4Create a small VM

    gcloud compute instances create web-1 --zone europe-west4-a --machine-type e2-small --image-family rocky-linux-9 --image-project rocky-linux-cloud
  5. 5SSH through IAP (no public IP)

    gcloud compute ssh web-1 --zone europe-west4-a --tunnel-through-iap
  6. 6Deploy a container to Cloud Run

    gcloud run deploy shop --image europe-west4-docker.pkg.dev/acme/apps/shop:1.4.0 --region europe-west4 --no-allow-unauthenticated
  7. 7Docker login for Artifact Registry

    gcloud auth configure-docker europe-west4-docker.pkg.dev
  8. 8Only names and states, as values for a script

    gcloud compute instances list --filter="status=RUNNING" --format="value(name,zone)"
  9. 9Give a service account a role (least privilege)

    gcloud projects add-iam-policy-binding acme-shop-prod --member="serviceAccount:ci@acme-shop-prod.iam.gserviceaccount.com" --role="roles/run.developer"
  10. 10Read the last errors of Cloud Run

    gcloud logging read 'resource.type="cloud_run_revision" AND severity>=ERROR' --limit 20 --freshness 1h
  11. 11Copy files to a bucket

    gcloud storage cp backup.tar.gz gs://acme-backups/2026-10-31/

انتبه

  • Service account key files are long-lived secrets; prefer Workload Identity Federation for GitHub Actions.
  • Check the active project (gcloud config list) before you delete anything.

الملفات

~/.config/gcloud/
Credentials and configurations.

رموز الخروج

0OK.
1Error.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man gcloud