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 What is the Databricks CLI?.
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 installed.
-
For Windows, you have winget, Chocolatey, or Windows Subsystem for Linux (WSL) installed.
Install the Databricks CLI
-
Install the Databricks CLI:
- Linux, macOS
- Windows
Use Homebrew to install the Databricks CLI by running the following two commands:
Bash
brew tap databricks/tap
brew install databricks -
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:
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.
-
Use the Databricks CLI to initiate OAuth token management locally by running the following command for each target account or workspace.
For account-level operations, in the following command, replace the following placeholders:
- Replace
<account-console-url>with your Databricks https://accounts.cloud.databricks.com. - Replace
<account-id>with your Databricks account ID. See Locate your account ID.
Bash
databricks auth login --host <account-console-url> --account-id <account-id>For workspace-level operations, in the following command, replace
<workspace-url>with your Databricks workspace instance URL, for examplehttps://dbc-a1b2345c-d6e7.cloud.databricks.com.Bash
databricks auth login --host <workspace-url> - Replace
-
The Databricks CLI prompts you to save the information that you entered as a Databricks configuration profile. Press
Enterto 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 commanddatabricks auth env --profile <profile-name>. -
In your web browser, complete the on-screen instructions to log in to your Databricks account or workspace.
-
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, 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
--hostand--account-idvalues, you might need to specify the--host,--account-id, and-poptions together to help the Databricks CLI find the correct matching OAuth token information.For workspace-level operations, 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
--hostvalues, you might need to specify the--hostand-poptions 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.
- For an overview of available CLI commands, see Databricks CLI commands.
- If the CLI does not run or produces unexpected results, see Verify your CLI installation.