How to Uninstall and Install azure-cli on Ubuntu 22.04

Updated: September 1, 2022

The Azure command-line interface (CLI) is Microsoft’s cross-platform command-line experience for managing Azure resources. The Azure CLI is designed to be easy to learn and get started with, but powerful enough to be a great tool for building custom automation to use Azure resources. In this tutorial, I will show you how to install azure-cli on Ubuntu 22.04.

Requirements

  • Operating system: Ubuntu 22.04 is needed for azure-cli to work
  • Privileges: Check that you can run sudo commands.

Prerequisites to install azure-cli on Ubuntu 22.04

Install azure-cli Ubuntu 22.04

azure-cli is one of the popular ways on Ubuntu now so that this tutorial will show you how to install it in various ways. Choose the one that you think is easy and you can follow.

Install azure-cli using APT

This is one of the most popular methods for installing Ubuntu packages because it’s easy to follow, even if you are a newbie in Linux. Following these instructions to get azure-cli on your Ubuntu 22.04.

Step 1: Update the APT database to download new packages from Ubuntu. Opening the terminal and executing the following Linux command:

sudo apt-get update

Step 2: Install the package on Ubuntu 22.04. After updating the system, you can install azure-cli Ubuntu by pasting this command into the terminal and executing it.

sudo apt-get install azure-cli

Install azure-cli using Aptitude

Users can manage their installation, upgrade, and removal of packages with Aptitude and view a list of the packages that are currently available. If you haven’t already installed it on Ubuntu, run this command to do so.

sudo apt-get -y install aptitude

Then, you can now install azure-cli, just following these steps:

Step 1: You must update the APT package repository cache before attempting to install, update, or remove any packages. Update the APT database to download new packages from Ubuntu. Launching the terminal and entering the following Linux command:

sudo apt-get -y update

Step 2: Start the package installation on Ubuntu 22.04. After updating, you can install azure-cli Ubuntu by pasting this command into the terminal and pressing Enter.

sudo aptitude -y install azure-cli

Uninstall azure-cli on Ubuntu 22.04

Have you ever considered how challenging it might be to uninstall an application from Ubuntu? You’re wrong, anyone can easily uninstall any program, not just a azure-cli.

This command can be used to uninstall azure-cli from Ubuntu 22.04 if it was installed using APT or Aptitude.

sudo apt remove --auto-remove azure-cli

You can also execute this command if you want to uninstall azure-cli and remove its data and dependencies:

sudo apt autoremove --purge azure-cli

Ending

In this guide, I showed you ways to install azure-cli on Ubuntu 22.04 and ways to uninstall azure-cli too. If you need any help, don’t hesitate to contact me. I’m very glad to answer them.