---
title: Basic usage for the Databricks CLI
description: Learn how to use the Databricks CLI to output available command groups and commands, output help, and work with CLI output.
canonical_url: https://docs.databricks.com/aws/en/dev-tools/cli/usage
---

# Basic usage for the Databricks CLI

> [!NOTE]
>
> Databricks CLI use is subject to the [Databricks License](https://github.com/databricks/cli?tab=License-1-ov-file#readme) and [Databricks Privacy Notice](https://www.databricks.com/legal/privacynotice), including any Usage Data provisions.

This page shows you how to list Databricks CLI [command groups and commands](https://docs.databricks.com/aws/en/dev-tools/cli/commands.md), display Databricks CLI help, and work with Databricks CLI output. See [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/index.md).

To install and configure authentication for the Databricks CLI, see [Databricks CLI tutorial](https://docs.databricks.com/aws/en/dev-tools/cli/tutorial.md).

## List available CLI commands

To list available CLI command groups, use the `--help` or `-h` option, for example:

```bash
databricks -h
```

To list the commands for any command group, use the `--help` or `-h` option. For example, to list the `clusters` commands:

```bash
databricks clusters -h
```

## Display CLI command help

To display usage information for a command, use the `--help` or `-h` option with the command. For example, to display the help for the `clusters list` command:

```bash
databricks clusters list -h
```

Command reference is also available. See [Databricks CLI commands](https://docs.databricks.com/aws/en/dev-tools/cli/commands.md).

## Run a command

Complete usage information and syntax for individual commands can be found in the command-line help and [reference](https://docs.databricks.com/aws/en/dev-tools/cli/commands.md), but [Databricks CLI commands](https://docs.databricks.com/aws/en/dev-tools/cli/commands.md) generally conform to the following syntax:

```
databricks <command-group> <command-name> <subcommand-name> [command-argument-value1] [--<flag1-name> <flag1-value>]
```

Not every command has additional subcommands. Global flags are available, and some commands have additional flags. For example, the following command outputs available clusters, using a command-specific flag:

```bash
databricks clusters list --can-use-client JOBS
```

> [!TIP]
>
> You can run Databricks CLI commands from within a Databricks workspace using the web terminal. The workspace web terminal can be used by many users on one compute and does not require you to configure authentication. See [Run shell commands in Databricks web terminal](https://docs.databricks.com/aws/en/compute/web-terminal.md).

### Example: Create a Databricks job

The following example uses the CLI to create a Databricks job. This job contains a single job task. This task runs the specified Databricks notebook. This notebook has a dependency on a specific version of the PyPI package named `wheel`. To run this task, the job temporarily creates a job cluster that exports an environment variable named `PYSPARK_PYTHON`. After the job runs, the cluster is terminated.

```bash
databricks jobs create --json '{
  "name": "My hello notebook job",
  "tasks": [
    {
      "task_key": "my_hello_notebook_task",
      "notebook_task": {
        "notebook_path": "/Workspace/Users/someone@example.com/hello",
        "source": "WORKSPACE"
      },
      "libraries": [
        {
          "pypi": {
            "package": "wheel==0.41.2"
          }
        }
      ],
      "new_cluster": {
        "spark_version": "13.3.x-scala2.12",
        "node_type_id": "i3.xlarge",
        "num_workers": 1,
        "spark_env_vars": {
          "PYSPARK_PYTHON": "/databricks/python3/bin/python3"
        }
      }
    }
  ]
}'
```

## JSON input and output

Some Databricks CLI commands have a `--json` flag or other options that accept JSON string input. In addition, some commands output a JSON string.

### String formatting

The format of JSON strings depends on your operating system:

#### Linux or macOS

Enclose JSON string parameters in double quotes and enclose the entire JSON payload in single quotes. For example:

```
'{"cluster_id": "1234-567890-abcde123"}'
```

```
'["20230323", "Amsterdam"]'
```

#### Windows

Enclose JSON string parameters and the entire JSON payload in double quotes, and precede the double-quote characters inside the JSON payload with a backslash (`\`). For example:

```
"{\"cluster_id\": \"1234-567890-abcde123\"}"
```

```
"[\"20230323\", \"Amsterdam\"]"
```

### Set fields in a JSON string

The `--json` flag on many commands enables you to set object fields that may not be available as CLI commands or options. For example, the following call adds a user with the ID `9ddddddd-1eee-4eee-a666-8fff7c111111` to the group with the ID `7eeeeeee-9ccc-4aaa-b777-1aaaaaaaaaa`:

#### Linux or macOS

```bash
databricks account groups patch 7eeeeeee-9ccc-4aaa-b777-1aaa2eeeee6f --json '{
  "schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
  "Operations": [
    {
      "op": "add",
      "path": "members",
      "value": [
        {
        "value": "9ddddddd-1eee-4eee-a666-8fff7c111111"
        }
      ]
    }
  ]
}'
```

#### Windows

```bash
databricks account groups patch 7eeeeeee-9ccc-4aaa-b777-1aaa2eeeee6f --json "{
  \"schemas\": [\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],
  \"Operations\": [
    {
      \"op\": \"add\",
      \"path\": \"members\",
      \"value\": [
        {
            \"value\": \"9ddddddd-1eee-4eee-a666-8fff7c111111\"
        }
      ]
    }
  ]
}"
```

### <a id="jq" />Filter JSON output with `jq`

For Databricks CLI commands that output JSON, you can use the [jq command-line processor](https://jqlang.github.io/jq/) to filter the output. For example, to list just the display name of a Databricks cluster with the specified cluster ID:

```bash
databricks clusters get 1234-567890-abcde123 | jq -r .cluster_name
```

```output
My-11.3-LTS-Cluster
```

You can install `jq` on macOS using Homebrew with `brew install jq` or on Windows using Chocolatey with `choco install jq`. For more information on `jq`, see the [jq Manual](https://jqlang.github.io/jq/manual/).

## Proxy server configuration

To route Databricks CLI requests and responses through a proxy server, set the `HTTPS_PROXY` environment variable on the machine where the Databricks CLI is installed to the proxy server's URL.

To set environment variables, see your operating system's documentation.
