---
title: Databricks CLI tutorial
description: Use this hands-on tutorial to quickly get started with the Databricks command-line interface (Databricks CLI), provided by Databricks.
canonical_url: https://docs.databricks.com/aws/en/dev-tools/cli/tutorial
---

# Databricks CLI tutorial

> [!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.

The Databricks command-line interface (also known as the Databricks CLI) utility provides an easy-to-use interface to automate the Databricks platform from your terminal, command prompt, or automation scripts. See [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/index.md).

This article demonstrates how to quickly install and configure the Databricks CLI.

## Confirm local machine requirements

This tutorial assumes that:

* For Linux or macOS, you have [Homebrew](https://brew.sh/) installed.

  > [!NOTE]
  >
  > For other ways to install the CLI if you cannot use Homebrew, see [Install or update the Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install.md).

* For Windows, you have [winget](https://learn.microsoft.com/windows/package-manager/winget/), [Chocolatey](https://docs.chocolatey.org/en-us/choco/setup), or [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/windows/wsl/about) installed.

  > [!NOTE]
  >
  > Installing the Databricks CLI with Chocolatey is [Experimental](https://docs.databricks.com/aws/en/release-notes/release-types.md). For other ways to install the CLI, see [Install or update the Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install.md).

## <a id="install" />Install the Databricks CLI

1. Install the [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install.md):

   ### Linux, macOS

   Use [Homebrew](https://brew.sh/) to install the Databricks CLI by running the following commands:

   ```bash
   brew tap databricks/tap
   brew trust databricks/tap
   brew install databricks
   ```

   The `brew trust` command is required as of [Homebrew 6.0.0](https://docs.brew.sh/Tap-Trust).

   ### Windows

   You can use [winget](https://learn.microsoft.com/windows/package-manager/winget/), [Chocolatey](https://docs.chocolatey.org/en-us/choco/setup) or [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/windows/wsl/about) to install the Databricks CLI. If you cannot use `winget`, Chocolatey, or WSL, you should skip this procedure and use the Command Prompt or PowerShell to [install the Databricks CLI from source](https://docs.databricks.com/aws/en/dev-tools/cli/install.md#source-install) instead.

   > [!NOTE]
   >
   > Installing the Databricks CLI with Chocolatey is [Experimental](https://docs.databricks.com/aws/en/release-notes/release-types.md).

   To use `winget` to install the Databricks CLI, run the following two commands, and then restart your Command Prompt:

   ```bash
   winget search databricks
   winget install Databricks.DatabricksCLI
   ```

   To use Chocolatey to install the Databricks CLI, run the following command:

   ```bash
   choco install databricks-cli
   ```

   To use WSL to install the Databricks CLI:

   1. Install `curl` and `zip` through WSL. For more information, see your operating system's documentation.
   2. Use WSL to install the Databricks CLI by running the following command:

      ```bash
      curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh
      ```

2. Confirm that the Databricks CLI is installed by running the following command, which displays the current version of the installed Databricks CLI. This version should be 0.205.0 or above:

   ```bash
   databricks -v
   ```

## <a id="auth" />Configure access to your workspace

Next, configure access to your Databricks workspace.

> [!NOTE]
>
> This tutorial uses OAuth user-to-machine (U2M) authentication to authenticate the CLI using your Databricks user account. To configure the CLI to use other Databricks authentication types, see [Authentication for the Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/authentication.md).

1. Use the [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install.md) to initiate OAuth token management locally by running the following command for each target account or workspace.

   For [account-level operations](https://docs.databricks.com/api/account), in the following command, replace the following placeholders:

   * Replace `<account-console-url>` with your Databricks [https://accounts.cloud.databricks.com](https://accounts.cloud.databricks.com).
   * Replace `<account-id>` with your Databricks account ID. See [Locate your account ID](https://docs.databricks.com/aws/en/admin/account-settings/index.md#account-id).

   ```bash
   databricks auth login --host <account-console-url> --account-id <account-id>
   ```

   For [workspace-level operations](https://docs.databricks.com/api/workspace), in the following command, replace `<workspace-url>` with your Databricks [workspace instance URL](https://docs.databricks.com/aws/en/workspace/workspace-details.md#workspace-url), for example `https://dbc-a1b2345c-d6e7.cloud.databricks.com`.

   ```bash
   databricks auth login --host <workspace-url>
   ```

2. The Databricks CLI prompts you to save the information that you entered as a Databricks [configuration profile](https://docs.databricks.com/aws/en/dev-tools/auth/config-profiles.md). Press `Enter` to accept the suggested profile name, or enter the name of a new or existing profile. Any existing profile with the same name is overwritten with the information that you entered. You can use profiles to quickly switch your authentication context among multiple accounts or workspaces.

   To get a list of any existing profiles, in a separate terminal or command prompt, use the Databricks CLI to run the command `databricks auth profiles`. To view a specific profile's existing settings, run the command `databricks auth env --profile <profile-name>`.

3. In your web browser, complete the on-screen instructions to log in to your Databricks account or workspace.

4. To view a profile's current OAuth token value and the token's upcoming expiration timestamp, run one of the following commands:

   For [account-level operations](https://docs.databricks.com/api/account), run the following commands:

   * `databricks auth token -p <profile-name>`
   * `databricks auth token --host <workspace-url> --account-id <account-id>`
   * `databricks auth token --host <workspace-url> --account-id <account-id> -p <profile-name>`

   If you have multiple profiles with the same `--host` and `--account-id` values, you might need to specify the `--host`, `--account-id`, and `-p` options together to help the Databricks CLI find the correct matching OAuth token information.

   For [workspace-level operations](https://docs.databricks.com/api/workspace), run the following commands:

   * `databricks auth token -p <profile-name>`
   * `databricks auth token --host <workspace-url>`
   * `databricks auth token --host <workspace-url> -p <profile-name>`

   If you have multiple profiles with the same `--host` values, you might need to specify the `--host` and `-p` options together to help the Databricks CLI find the correct matching OAuth token information.

## Next steps

* To learn how to use the CLI, see [Basic usage for the Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/usage.md).
* For an overview of available CLI commands, see [Databricks CLI commands](https://docs.databricks.com/aws/en/dev-tools/cli/commands.md).
* If the CLI does not run or produces unexpected results, see [Verify your CLI installation](https://docs.databricks.com/aws/en/dev-tools/cli/migrate.md#verify-install).
