Clicking through the Azure portal is fine for learning, but real system administration needs repeatability. The Azure CLI lets you create, inspect and automate every Azure resource from a terminal — and it runs natively on Linux. In this guide you will install Azure CLI on Ubuntu or Debian, sign in, and learn the essential commands every sysadmin should know. This article covers Install Azure CLI on Linux and in detail.
Why Azure CLI Matters for Sysadmins – Install Azure CLI on Linux and
With the Azure CLI you can script an entire environment build, audit resources across subscriptions in seconds, and manage servers over an SSH session without a browser. Every command returns structured JSON, so output pipes cleanly into tools like jq.
Step 1: Install Azure CLI on Ubuntu and Debian – Install Azure CLI on Linux and
Microsoft publishes an official apt repository. Add it and install:
sudo apt update
sudo apt install -y ca-certificates curl apt-transport-https lsb-release gnupg
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 "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_DIST main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt update
sudo apt install -y azure-cli
On RHEL-family systems the same package is available via a Microsoft dnf repository. Verify the installation:
az version
Step 2: Sign In and Select a Subscription
az login
az account list --output table
az account set --subscription "My Subscription"
az account show
On a headless server without a browser, use az login --use-device-code and complete the sign-in from any other device. For automation, service principals or managed identities are the right choice instead of personal accounts.

Step 3: Control Output with –output and –query
Two flags transform the Azure CLI from a viewer into an automation tool:
az vm list --output table
az vm list --query "[].{Name:name, RG:resourceGroup, Location:location}" --output table
az group list --query "[].name" --output tsv
The --query flag uses JMESPath expressions to filter and reshape JSON before it reaches your scripts.
15 Essential Azure CLI Commands for Sysadmins
az account show— confirm which subscription you are operating onaz group list— list all resource groupsaz resource list --resource-group rg-linux-prod— inventory everything in a groupaz vm list -d --output table— all VMs with IPs and power stateaz vm start --resource-group rg --name vm-web-01— power on a VMaz vm stop --resource-group rg --name vm-web-01— stop a VM (still billed for disks)az vm deallocate --resource-group rg --name vm-web-01— stop and release compute billingaz vm restart --resource-group rg --name vm-web-01— reboot a VMaz network vnet list --output table— list virtual networksaz network nsg rule list --resource-group rg --nsg-name vm-web-01NSG --output table— audit firewall rulesaz storage account list --output table— list storage accountsaz monitor metrics list --resource <vm-resource-id> --metric "Percentage CPU"— pull performance metricsaz vm run-command invoke --resource-group rg --name vm-web-01 --command-id RunShellScript --scripts "uptime"— run a shell command inside a VM without SSHaz find "az vm create"— search the built-in help for the right commandaz upgrade— update the CLI itself to the latest release
Step 4: Set Defaults to Type Less
az configure --defaults group=rg-linux-prod location=eastus output=table
Now commands such as az vm list automatically target your default group and print readable tables. The full syntax for every command group is documented in the official Azure CLI installation and reference pages on Microsoft Learn.
Working Faster: Extensions, Interactive Mode and Aliases
Three quality-of-life features reward exploration once the basics feel comfortable. az interactive launches an auto-completing shell that shows command help, parameter suggestions and examples as you type — the fastest way to discover unfamiliar command groups. Extensions add community and preview functionality: az extension list-available shows what exists, and az extension add --name ssh installs the popular SSH extension that lets you connect to VMs through Azure AD and bastion-style paths. Finally, plain bash aliases pay off daily; many sysadmins alias az vm list -d -o table to a two-letter shortcut in their .bashrc. Pair these with shell completion (az ships bash and zsh completers) and the CLI becomes quicker than any portal for repeat work.
Troubleshooting
- az: command not found after install: open a new shell so PATH changes take effect, or check
which az. - Please run “az login” to access this subscription: your token expired. Re-run
az login; in scripts, switch to a service principal. - SubscriptionNotFound errors: you are probably pointing at the wrong subscription — verify with
az account showbefore running destructive commands. - Slow first run: the CLI builds a local command index on first use; subsequent runs are fast.
Conclusion
With Azure CLI installed and these core commands in your toolbox, you can manage VMs, networks, storage and monitoring from any terminal. The natural next steps are writing small bash scripts around az vm and az monitor, and learning how these commands map to the Azure resources used throughout our other Azure tutorials.
Related reading: Azure Blob Storage Tiers: Hot, Cool, and Archive Guide