Skip to main content

az: command not found — Fix the Azure CLI Install and PATH

Fix `az: command not found` and `zsh: command not found: az` on Linux, macOS, WSL, and Windows. Tell a missing install apart from a broken PATH in one command.

8 min readUpdated August 2026

When your shell prints az: command not found, it searched every directory in your PATH and found no executable named az. There are only two possible causes: the Azure CLI is not installed, or it is installed somewhere your PATH does not cover.

$ az login
bash: az: command not found

$ az --version
zsh: command not found: az

One command tells you which one you have:

command -v az

If it prints a path, the CLI is installed and you have a PATH problem. If it prints nothing, you have an installation problem. Do not skip this step — the two have completely different fixes, and guessing wastes the most time.

Fix 1: Restart Your Terminal First (Windows Especially)

Before reinstalling anything, close the terminal and open a new one.

A running shell keeps the environment it started with, so an installer that adds a directory to PATH has no effect on windows that were already open. Microsoft states this directly in the Windows install guide: after installation you must close and reopen any active terminal window to use the Azure CLI, and lists "PATH variable not set" as most commonly caused by exactly this.

This applies to VS Code's integrated terminal too — reload the window, or the terminal keeps the environment VS Code inherited at launch.

Fix 2: Install the Azure CLI

Ubuntu, Debian, and WSL

The maintained one-line script runs every documented step:

curl -fsSL 'https://azurecliprod.blob.core.windows.net/$root/deb_install.sh' | sudo bash

If you would rather inspect each step — reasonable for a script running as root — do it manually:

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

sudo mkdir -p /etc/apt/keyrings
curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
  gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/microsoft.gpg

AZ_DIST=$(lsb_release -cs)
echo "Types: deb
URIs: https://packages.microsoft.com/repos/azure-cli/
Suites: ${AZ_DIST}
Components: main
Architectures: $(dpkg --print-architecture)
Signed-by: /etc/apt/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/azure-cli.sources

sudo apt-get update
sudo apt-get install azure-cli

If apt replies Unable to locate package azure-cli, the repository step did not take effect — azure-cli is not in the stock Ubuntu or Debian archives. Re-run the repository and key steps, then apt-get update again.

On Linux Mint and other derivatives, lsb_release -cs may return a name Microsoft does not publish packages for. Set the Suites: value manually to the upstream code name your distribution is based on, such as jammy for Ubuntu or bookworm for Debian.

Advertisement

RHEL, CentOS Stream, and Fedora

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf install -y https://packages.microsoft.com/config/rhel/9.0/packages-microsoft-prod.rpm
sudo dnf install azure-cli

macOS

brew update && brew install azure-cli

Windows

winget install --exact --id Microsoft.AzureCLI

The MSI installer is the alternative, and it overwrites any existing installation, so you do not need to uninstall first. Either way — close and reopen your terminal afterwards.

Fix 3: Repair a Broken PATH

If command -v az printed a path but a new shell still cannot find it, the directory is missing from your shell profile. Find the binary, then add its directory:

ls -l /usr/bin/az /usr/local/bin/az /opt/homebrew/bin/az 2>/dev/null
echo "$PATH" | tr ':' '\n'

Add the directory to the profile your shell actually reads — ~/.zshrc for zsh (the macOS default), ~/.bashrc or ~/.bash_profile for bash:

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

On Apple Silicon Macs, Homebrew installs to /opt/homebrew; on Intel Macs it is /usr/local. Following an Intel-era guide on an Apple Silicon machine is a routine cause of this error.

Two more environment-specific cases:

  • sudo az ... fails while az ... works. sudo resets PATH for security. You almost never need sudo for az — it operates on cloud resources, not local system files.
  • cron and CI runners start with a minimal PATH. Use the absolute path to the binary, or set PATH explicitly at the top of the job.

Verify the Fix

az version
command -v az

Then confirm the CLI can actually reach Azure:

az login
az account show

az account show returning your subscription confirms installation, PATH, and authentication are all working. From there you can move on to real work, such as creating a storage account or assigning roles.

Prevent It From Recurring

  • Install through a package manager — apt, dnf, Homebrew, or WinGet — so upgrades and PATH are handled for you. Avoid sudo pip install, which creates root-owned files that break later upgrades.
  • Keep PATH edits in one place. Duplicated exports scattered across .bashrc, .zshrc, and .profile are how these errors reappear months later.
  • Open a new terminal after any install rather than debugging a stale environment.
  • Pin the CLI version in CI and install it as an explicit build step, so a runner image change cannot silently remove it.
  • Update in place with az upgrade instead of layering a second installation on top of the first.

Frequently Asked Questions

Find answers to common questions

Your shell searched every directory in PATH and found no executable named az. Either the Azure CLI is not installed, or it is installed somewhere your PATH does not include. Run 'command -v az' to tell the two apart — no output at all means the shell cannot see it anywhere.

Install the CLI with 'brew update && brew install azure-cli', then open a new terminal. If it is already installed, the Homebrew binary directory is missing from PATH — on Apple Silicon that is /opt/homebrew/bin and on Intel Macs it is /usr/local/bin. Add the right one to your ~/.zshrc.

Close and reopen the terminal. Microsoft calls this out explicitly: after installation you must close and reopen any active terminal window, because a running shell keeps the PATH it started with. This is the single most common cause on Windows.

The quickest documented route is the maintained script: curl -fsSL 'https://azurecliprod.blob.core.windows.net/$root/deb_install.sh' | sudo bash. If you prefer to inspect each step, add the Microsoft signing key to /etc/apt/keyrings, add the azure-cli repository, then run sudo apt-get update && sudo apt-get install azure-cli.

The Azure CLI repository is not configured on the machine — azure-cli is not in the default Ubuntu or Debian archives. Add the Microsoft repository and signing key first, then apt-get update, then install. Microsoft documents this exact message as the symptom of a missing repository.

No. az login is a subcommand of the same az binary. If az itself is not found, no subcommand will work. Fix the installation or PATH first, then run az login.

PATH is set per shell session and per shell. A change added to ~/.zshrc does not affect an already-open bash session, VS Code's integrated terminal may start with a different environment, and sudo resets PATH entirely. Open a fresh terminal of the same shell you configured.

WSL is a separate Linux environment with its own filesystem and PATH — the Windows installation is not visible to it as az. Install the Linux package inside your WSL distribution using the same apt steps you would use on Ubuntu.

No. Use your distribution's package manager, the maintained install script, Homebrew on macOS, or the MSI and WinGet packages on Windows. Installing Python packages system-wide with sudo creates root-owned files that break later upgrades and can conflict with system Python.

Run 'az version' for the installed version and 'command -v az' for the path being used. Then run 'az login' followed by 'az account show' to confirm the CLI can authenticate and see a subscription.