# How to Install and Configure doctl ## Step 1: Install doctl Install `doctl` following the directions for your package manager or operating system: ## Homebrew (macOS) To install the latest version of `doctl` using Homebrew on macOS, run: ``` brew install doctl ``` ## Snap Package (Ubuntu) To install the latest version of `doctl` using Snap on Ubuntu or [other supported operating systems](https://snapcraft.io/docs/installing-snapd), run: ``` sudo snap install doctl ``` For security purposes, Snaps run in complete isolation and need to be granted permission to interact with your system’s resources. Some `doctl` commands require additional permissions: - Using `doctl`’s integration with `kubectl` requires the `kube-config` [personal-files interface](https://snapcraft.io/docs/personal-files-interface). To enable it, run: ``` sudo snap connect doctl:kube-config ``` - Using `doctl compute ssh` requires the core [ssh-keys interface](https://docs.snapcraft.io/ssh-keys-interface). To enable it, run: ``` sudo snap connect doctl:ssh-keys :ssh-keys ``` - Using `doctl registries login` requires the `dot-docker` [personal-files interface](https://snapcraft.io/docs/personal-files-interface). To enable it, run: ``` sudo snap connect doctl:dot-docker ``` ## GitHub Download (Linux, macOS) Visit the [Releases page](https://github.com/digitalocean/doctl/releases) for the `doctl` GitHub project and find the appropriate archive for your operating system and architecture. Download the archive from your browser or copy its URL and retrieve it to your home directory with `wget`. For example, to download the most recent version of `doctl` for Linux with `wget`, run: ``` cd ~ wget https://github.com/digitalocean/doctl/releases/download/v1.152.0/doctl-1.152.0-linux-amd64.tar.gz ``` Next, extract the binary. For example, to do so using `tar`, run: ``` tar xf ~/doctl-1.152.0-linux-amd64.tar.gz ``` Finally, move the `doctl` binary into your path by running: ``` sudo mv ~/doctl /usr/local/bin ``` ## GitHub Download (Windows) Visit the [Releases page](https://github.com/digitalocean/doctl/releases) for the `doctl` GitHub project and find the appropriate archive for your operating system and architecture. Download the archive from your browser or copy its URL and retrieve using PowerShell. For example, to download the most recent version of `doctl`, run: ``` Invoke-WebRequest https://github.com/digitalocean/doctl/releases/download/v1.152.0/doctl-1.152.0-windows-amd64.zip -OutFile ~\doctl-1.152.0-windows-amd64.zip ``` Next, extract the binary by running: ``` Expand-Archive -Path ~\doctl-1.152.0-windows-amd64.zip ``` Finally, in a PowerShell terminal opened with **Run as Administrator**, move the `doctl` binary into a dedicated directory and add it to your system’s path by running: ``` New-Item -ItemType Directory $env:ProgramFiles\doctl\ Move-Item -Path ~\doctl-1.152.0-windows-amd64\doctl.exe -Destination $env:ProgramFiles\doctl\ [Environment]::SetEnvironmentVariable( "Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";$env:ProgramFiles\doctl\", [EnvironmentVariableTarget]::Machine) $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") ``` ## Step 2: Create an API token [Create a DigitalOcean API token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) for your account with read and write access from the [Applications & API page](https://cloud.digitalocean.com/account/api/tokens) in the control panel. The token string is only displayed once, so save it in a safe place. ## Step 3: Use the API token to grant account access to doctl **Note**: If you installed `doctl` using the Ubuntu Snap package, you may need to first create the user configuration directory if it does not exist yet by running `mkdir ~/.config`. Use the API token to grant doctl access to your DigitalOcean account. Pass in the token string when prompted by `doctl auth init`, and give this authentication context a name. ```bash doctl auth init --context ``` Authentication contexts let you switch between multiple authenticated accounts. You can repeat steps 2 and 3 to add other DigitalOcean accounts, then list and switch between authentication contexts: ```bash doctl auth list doctl auth switch --context ``` ## Step 4: Validate that doctl is working Now that `doctl` is authorized to use your account, try some test commands. To confirm that you have successfully authorized `doctl`, [review your account details](https://docs.digitalocean.com/reference/doctl/reference/account/get/index.html.md) by running: ```bash doctl account get ``` If successful, the output looks like: ``` Email Droplet Limit Email Verified UUID Status sammy@example.org 10 true 3a56c5e109736b50e823eaebca85708ca0e5087c active ``` To confirm that you have successfully granted write access to `doctl`, [create an Ubuntu 24.04 Droplet](https://docs.digitalocean.com/reference/doctl/reference/compute/droplet/create/index.html.md) in [the SFO2 region](https://docs.digitalocean.com/platform/regional-availability/index.html.md) by running: ```bash doctl compute droplet create --region sfo2 --image ubuntu-24-04-x64 --size s-1vcpu-1gb ``` The output of that command includes an **ID** column with the new Droplet’s ID. For example: ``` ID Name Public IPv4 Private IPv4 Public IPv6 Memory VCPUs Disk Region Image Status Tags Features Volumes 187949338 droplet-name 1024 1 25 sfo2 Ubuntu 24.04 (LTS) x64 new ``` Use that value to [delete the Droplet](https://docs.digitalocean.com/reference/doctl/reference/compute/droplet/delete/index.html.md) by running: ```bash doctl compute droplet delete ``` When prompted, type `y` to confirm that you would like to delete the Droplet. ## Step 5: Install Serverless Functions support (Optional) To use `doctl` with [our serverless Functions product](https://docs.digitalocean.com/products/functions/index.html.md), you must first install a software extension, then use it to connect to the development namespace. To install the support for serverless Functions, run the `serverless install` subcommand: ```bash doctl serverless install ``` This downloads and installs the extension, providing status updates along the way: ``` Downloading...Unpacking...Installing...Cleaning up... Done ``` You are now ready to create a namespace and deploy your functions. See the [Functions Quickstart](https://docs.digitalocean.com/products/functions/getting-started/quickstart/index.html.md) to get started.