Inizializzazione dell'interfaccia a riga di comando gcloud
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina mostra come inizializzare gcloud CLI.
Dopo aver installato gcloud CLI, esegui le attività di configurazione iniziale eseguendo
gcloud init. Puoi anche eseguire gcloud init
per modificare le impostazioni o creare una nuova configurazione.
gcloud init esegue i seguenti passaggi di configurazione:
Autorizza gcloud CLI a utilizzare le credenziali del tuo account utente per accedere Google Cloudoppure ti consente di selezionare un account se hai autorizzato l'accesso in precedenza.
Configura una configurazione
gcloud CLI e imposta un insieme di base di proprietà, tra cui
l'account attivo del passaggio precedente, il progetto corrente e, se
applicabile, la regione e la zona di Compute Engine predefinite
Puoi eseguire i seguenti comandi come alternative a gcloud init:
Crea e gestisci configurazioni e proprietà di gcloud CLI.
Inizializza gcloud CLI
Per inizializzare gcloud CLI:
Corsa gcloud init:
gcloud init
Se ti trovi in una sessione del terminale remoto, puoi utilizzare il flag --no-launch-browser
per impedire al comando di avviare un flusso di autorizzazione basato sul browser, se necessario:
gcloud init --no-launch-browser
Crea o seleziona una configurazione, se richiesto.
Se stai inizializzando una nuova installazione di gcloud CLI,gcloud init crea una configurazione denominata default e la imposta come configurazione attiva. Se hai configurazioni esistenti,
gcloud init ti chiede di scegliere tra tre opzioni: reinizializzare quella attiva, passare a un'altra e reinizializzarla o crearne una nuova.
Completa il passaggio di autorizzazione quando ti viene richiesto.
A seconda che tu abbia già autorizzato l'accesso a
Google Cloud, potrebbe esserti chiesto di accedere e concedere l'accesso in un
browser web o di selezionare un account esistente.
Se hai utilizzato il flag --no-launch-browser e l'accesso è obbligatorio,
devi copiare e incollare l'URL di autorizzazione fornito in un'altra
finestra del browser e seguire le istruzioni fornite.
Una volta completato questo passaggio, gcloud init imposta la proprietà account nella
configurazione sull'account specificato.
Se richiesto, scegli un progetto Google Cloud corrente.
Se hai accesso a un solo progetto, incluso quello predefinito per il tuo account utente, gcloud init lo seleziona automaticamente.
In alternativa, puoi
selezionare un progetto da un elenco di progetti per i quali disponi delle autorizzazioni Proprietario,
Editor o Visualizzatore. gcloud init imposta la proprietà project
nella configurazione sulla proprietà che scegli. Se hai accesso a più di 200 progetti, ti verrà chiesto di inserire un ID progetto, creare un nuovo progetto o elencare i progetti.
This account has a lot of projects! Listing them all can take a while.
[1] Enter a project ID
[2] Create a new project
[3] List projects
Please enter your numeric choice:
Se richiesto, scegli una zona di Compute Engine predefinita.
Se non hai abilitato l'API Compute Engine o hai già una zona predefinita nei
metadati a livello di progetto, non vedrai questo passaggio. gcloud init imposta le proprietà region e zone nella
configurazione utilizzando la zona che scegli.
Per visualizzare le proprietà impostate tramite il comando gcloud init, utilizza il comando
gcloud config list.
[compute]
region = us-east1
zone = us-east1-b
[core]
account = dana@example.com
disable_usage_reporting = False
project = example-project
Passaggi successivi
Per scoprire di più sull'autorizzazione dello strumento,
consulta Autorizzare gcloud CLI.
Per scoprire di più sull'autorizzazione Credenziali predefinite dell'applicazione (ADC) per le librerie client Cloud (e le librerie client delle API di Google), consulta Configurare le credenziali predefinite dell'applicazione.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-25 UTC."],[],[],null,["This page shows you how to initialize the gcloud CLI.\n\nAfter you install the gcloud CLI, perform initial setup tasks by running\n[`gcloud init`](/sdk/gcloud/reference/init). You can also run `gcloud init`\nto change your settings or create a new configuration.\n\n`gcloud init` performs the following setup steps:\n\n- [Authorizes](/sdk/docs/authorizing) the gcloud CLI to use your user account credentials to access Google Cloud, or lets you select an account if you have previously authorized access\n- Sets up a gcloud CLI [configuration](/sdk/docs/configurations) and sets a base set of [properties](/sdk/docs/properties), including the active account from the step above, the current project, and if applicable, the default Compute Engine region and zone\n\nYou can run the following as alternatives to `gcloud init`:\n\n| Command | Description |\n|---------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|\n| [`gcloud auth login`](/sdk/gcloud/reference/auth/login) | Authorize with a user account without setting up a configuration. |\n| [`gcloud auth activate-service-account`](/sdk/gcloud/reference/auth/activate-service-account) | Authorize with a service account instead of a user account. Useful for authorizing non-interactively and without a web browser. |\n| [`gcloud config [COMMAND]`](/sdk/gcloud/reference/config) [`gcloud config configurations [COMMAND]`](/sdk/gcloud/reference/config/configurations) | Create and manage gcloud CLI configurations and properties. |\n\nInitialize the gcloud CLI\n\nTo initialize the gcloud CLI:\n\n1. Run `gcloud init`:\n\n gcloud init\n\n If you are in a remote terminal session, you can use the `--no-launch-browser`\n flag to prevent the command from launching a browser-based authorization\n flow, if required: \n\n gcloud init --no-launch-browser\n\n2. Create or select a configuration if prompted.\n\n If you are initializing a new gcloud CLI installation,\n `gcloud init` creates a configuration named `default` for you and sets\n it as the active configuration. If you have existing configurations,\n `gcloud init` prompts you to choose between three options ---\n re-initialize the active one, switch to another one and re-initialize it, or\n create a new one.\n3. Complete the authorization step when prompted.\n\n Depending on whether you have previously authorized access to\n Google Cloud, you might be prompted to log in and grant access in a\n web browser or to select an existing account.\n\n If you used the `--no-launch-browser` flag and login is required,\n you must then copy and paste the provided authorization URL into another\n browser window and follow the prompts provided.\n\n When this step is completed, `gcloud init` sets the `account` property in\n the configuration to the specified account.\n4. Choose a current Google Cloud project if prompted.\n\n If you only have access to one project, including the default project for\n your user account, `gcloud init` selects it for you.\n\n Otherwise, you can\n select a project from a list of projects for which you have **Owner** ,\n **Editor** or **Viewer** permissions. `gcloud init` sets the `project`\n property in the configuration to the property you choose. If you have\n access to more than 200 projects, you will be prompted to enter\n a project id, create a new project, or list projects. \n\n ```\n This account has a lot of projects! Listing them all can take a while.\n [1] Enter a project ID\n [2] Create a new project\n [3] List projects\n Please enter your numeric choice:\n ```\n | **Note:** If you choose to create a project, you'll also need to [enable billing on your project](/billing/docs/how-to/modify-project) to use Google Cloud services.\n5. Choose a default Compute Engine zone if prompted.\n\n If you don't have the Compute Engine API enabled or you already\n have a default zone in your\n [project-level metadata](/compute/docs/metadata), you will not see this\n step. `gcloud init` sets the `region` and `zone` properties in the\n configuration using the zone you choose.\n\nTo view the properties set through the `gcloud init` command, use the\n[`gcloud config list`](/sdk/gcloud/reference/config/list) command. \n\n```sh\n[compute]\nregion = us-east1\nzone = us-east1-b\n[core]\naccount = dana@example.com\ndisable_usage_reporting = False\nproject = example-project\n```\n\nWhat's next\n\n- To learn more about tool authorization, see [Authorizing the gcloud CLI](/sdk/docs/authorizing).\n- To learn more about authorizing Application Default Credentials (ADC) for Cloud Client Libraries (and Google API Client Libraries), see [Set up Application Default Credentials](/docs/authentication/provide-credentials-adc#how-to).\n- To learn more about managing configurations, see [gcloud CLI configurations](/sdk/docs/configurations).\n- To learn more about managing properties, see [gcloud CLI properties](/sdk/docs/properties)."]]