Sub topic 5
Core CLI command groups
This chapter assumes you have installed the Databricks CLI, authenticated, and saved a profile. It also assumes you know what jobs, clusters, and notebooks are in the workspace. Here you learn how the CLI is organized and how to find the right command.
How commands are organized
The CLI follows one pattern: databricks <group> <subcommand> [arguments] [flags]. Each group maps to a part of the Databricks REST API, so a subcommand usually corresponds to one endpoint. If you know the API, you can guess the command.
| Group | What it manages | Example subcommand |
|---|---|---|
| `current-user` | The identity the CLI uses | `me` |
| `clusters` | Compute clusters | `list`, `get`, `start` |
| `jobs` | Job definitions and runs | `list`, `get`, `run-now` |
| `workspace` | Notebooks and folders | `list`, `export`, `import` |
| `fs` | Files in DBFS and volumes | `ls`, `cp` |
| `bundle` | Asset Bundles | `validate`, `deploy` |
| `auth` | Login and profiles | `login`, `profiles` |
Run databricks --help to see every group. Run databricks jobs --help to see its subcommands. Run databricks jobs list --help to see the flags for one command.
Selecting a workspace
Every command accepts -p (or --profile) to choose a saved profile. Without it, the CLI uses the DEFAULT profile or the environment variables you set.
databricks current-user me -p dev
databricks clusters list -p prodRun current-user me first when something looks wrong. It shows which user and workspace the CLI is acting as.
Reading and acting on resources
Most groups follow a read-then-act pattern. You list resources to find an ID, inspect one by ID, and then act on it.
databricks clusters list
databricks clusters get <cluster-id>
databricks clusters start <cluster-id>Positional arguments are usually the ID of the resource. Commands with many fields, such as creating a job, take a --json flag. The value is either an inline JSON string or @file.json to read from a file.
databricks jobs run-now --json '{"job_id": 123}'The JSON body uses the same field names as the REST API. This makes API documentation directly useful for CLI work.
Output formats
By default the CLI prints human-readable text. Add --output json to get JSON that scripts can parse. The next chapter covers processing it with jq.
databricks jobs list --output jsonCommon errors
- Authentication errors. A
401or "cannot configure default credentials" message means the profile is missing, expired, or not selected. Rundatabricks auth profilesto check which profiles are valid. - Permission errors. A
403means you are authenticated, but your user cannot access that resource. Check the workspace permissions, not the CLI setup. - Wrong workspace. Commands succeed but show unexpected data. Confirm the host with
current-user meand pass-pexplicitly in scripts. - Unknown command. Group names can differ from UI names. Use
--helpinstead of guessing.
A quick command map
Exercise
You run databricks clusters list and see clusters you do not recognize. What two things should you check first, and which commands do you use?
Show answer
Check which identity and workspace the CLI is using with databricks current-user me, and check the available profiles with databricks auth profiles. The CLI probably used the default profile or environment variables instead of the intended workspace. Rerun the command with -p <profile>.
Exercise
You want to start a job whose definition is stored in the workspace, using the CLI. Which subcommand and flag do you use, and where do the field names come from?
Show answer
Use databricks jobs run-now --json '{"job_id": 123}'. The field names match the Jobs REST API request body.