Install Azure CLI 2.0 on Linux manually

If you do not have a package for the Azure CLI available on your distribution, you can always install the CLI manually by running an installation script.

Note

It's strongly recommend that you use a package manager for the CLI. A package manager makes sure you always get the latest updates, and guarantees the stability of CLI components. Check and see if there is a package for your distribution before installing manually.

Prerequisites

In order to install the CLI, you need the following software available on your system:

Install or update

Whether you are installing or updating the CLI, you need to perform a full installation. Once you have the prerequisites, you can install the CLI by running curl.

curl -L https://aka.ms/InstallAzureCli | bash

You can also download the script and run it locally instead. You may have to restart your shell in order for changes to take effect.

You can then run the Azure CLI with the az command. To sign in, use az login command.

  1. Run the login command.

    az login
    

    If the CLI can determine your default browser and has access to open it, it will do so and direct you immediately to a sign in page.

    Otherwise, you need to open a browser page and follow the instructions on the command line to enter an authorization code after navigating to https://aka.ms/devicelogin in your browser.

  2. Sign in with your account credentials in the browser.

To learn more about different authentication methods, see Sign in with Azure CLI 2.0.

Troubleshooting

Here are some common problems seen during a manual installation. If your issue is not listed here, please file an issue on github.

curl "Object Moved" error

If you get an error from curl related to the -L parameter, or an error message including the text "Object Moved", try using the full URL instead of the aka.ms redirect:

curl https://azurecliprod.blob.core.windows.net/install | bash

az command not found

If you can't run the command after installation and using bash or zsh, clear your shell's command hash cache. Run

hash -r

and check if the problem is resolved.

The issue can also occur if you did not restart your shell after installation. Make sure that the location of the az command is in your $PATH. The location of the az command is

<install path>/bin

Uninstall

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to give some information about why you chose to uninstall and how the CLI could be improved. Our goal is to make the Azure CLI bug-free and user-friendly. If you encountered a bug, we'd appreciate it if you file a GitHub issue.

Uninstall the CLI by directly deleting the files from the location chosen at the time of installation. The default install location is $HOME.

  1. Remove the installed CLI files.

    rm -r <install location>/lib/azure-cli
    rm <install location>/bin/az
    
  2. Modify your $HOME/.bash_profile file to remove the following line:

    <install location>/lib/azure-cli/az.completion
    
  3. If using bash or zsh, reload your shell's command cache.

    hash -r