To install and initialize the Distributed Cloud CLI,
[download the CLI bundle](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/resources/gdcloud-download.md.txt) and complete
the following steps.

## Add gdcloud CLI bin directory to path

Google recommends adding the gdcloud CLI `bin` directory to your
path.

When the `bin` directory is added to your path:

- You won't have to specify the entire directory structure with each command.
- Crucial gdcloud CLI components are installed in the `bin` directory that allow commands like `gdcloud components` to work correctly.

> [!NOTE]
> **Note:** The commands in the following sections assume the `google-distributed-cloud-hosted-cli` folder is in the current working directory.

Add the gdcloud CLI `bin` directory to your path:

```bash
eval echo 'export GDCLOUD_PATH=$(pwd)/google-distributed-cloud-hosted-cli' >> ~/.bashrc
echo 'export PATH="$GDCLOUD_PATH/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```

## Initialize gdcloud CLI default configuration

Initialize the gdcloud CLI default configuration:

```bash
gdcloud init
```

Follow the prompted instructions to initialize the configuration. You must
provide two properties to complete the initialization:

- `organization_console_url`: The URL to your current GDC
  organization's console. This URL can be global or zonal:

  - For a global console URL, use the syntax `https://console.ORG_NAME.SUFFIX`, such as `https://console.org-1.gdch.google.com`.
  - For a zonal console URL, use the syntax `https://console.ORG_NAME.ZONE.SUFFIX`, such as `https://console.org-1.zone-1.gdch.google.com`.

  Contact your Infrastructure Operator or Platform Administrator if you don't
  know your organization's console URL. If you're trying out the
  gdcloud CLI in
  [Google Distributed Cloud Sandbox](https://docs.cloud.google.com/distributed-cloud/sandbox/latest/overview.md.txt), see the
  GDC Sandbox
  [CLI setup instructions](https://docs.cloud.google.com/distributed-cloud/sandbox/latest/gdcloud.md.txt)
  for your instance's console URL.
- `project`: The name of your current GDC project.

View these properties using the `gdcloud config list` command.

## Manage gdcloud CLI components

Components are installable parts of the GDC CLI. The
gdcloud CLI is installed by default. List, install, and update
gdcloud CLI components as needed.

### List components

View the current list of available components:

```bash
gdcloud components list
```

### Install components

Install a component on the current version of your gdcloud CLI
installation:

```bash
gdcloud components install COMPONENT_ID
```

For example, this command installs the `kubectl` component:

```bash
gdcloud components install kubectl
```

### Update components

To update all GDC components to the latest version of
the gdcloud CLI, see
[Upgrade to the latest gdcloud CLI](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/resources/gdcloud-upgrade.md.txt).