How to Install AWS CLI v2 on Ubuntu 22.04

The AWS CLI v2 is the primary tool for managing AWS resources from the terminal. This guide shows you how to install AWS CLI v2 on Ubuntu 22.04 using the official installer from AWS, configure your credentials, and verify everything works.

The examples in this guide are run on WSL2 Ubuntu in Windows, but they work the same on EC2 instances or any Ubuntu system.

Prerequisites

  • Ubuntu 22.04 LTS — on WSL2, EC2, or bare metal
  • sudo privileges
  • An AWS account with access credentials (for the configuration step)

Install AWS CLI v2

Download the official installer, extract it, and run the install script:

sudo apt update && sudo apt install -y unzip curl
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
  • curl — downloads the official AWS CLI v2 zip package
  • unzip — extracts the installer
  • sudo ./aws/install — installs the CLI to /usr/local/aws-cli and creates a symlink at /usr/local/bin/aws

Clean up the downloaded files after installation:

rm -rf awscliv2.zip aws/

For ARM64 systems (Graviton EC2 instances)

If you’re on an ARM-based instance (like AWS Graviton), use the ARM64 package instead:

curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Verify the Installation

aws --version

You should see output like:

aws-cli/2.27.41 Python/3.13.1 Linux/5.15.167.4-microsoft-standard-WSL2 exe/x86_64.ubuntu.22

Update an Existing Installation

If you already have AWS CLI v2 installed and want to update it to the latest version, add the --update flag:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -o awscliv2.zip
sudo ./aws/install --update
rm -rf awscliv2.zip aws/
  • --update — overwrites the existing installation instead of failing with “already installed”
  • unzip -o — overwrites existing extracted files without prompting

Configure AWS Credentials

Run the interactive configuration to set up your default profile:

aws configure

You’ll be prompted for four values:

AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID
AWS Secret Access Key [None]: YOUR_SECRET_ACCESS_KEY
Default region name [None]: ap-southeast-1
Default output format [None]: json

This stores your credentials in ~/.aws/credentials and your region/output preferences in ~/.aws/config.

Verify your credentials are working:

aws sts get-caller-identity

This returns your AWS account ID, user ARN, and user ID — confirming the CLI can authenticate with AWS.

Using AWS SSO instead of access keys

If your organization uses AWS IAM Identity Center (SSO), you can configure the CLI with aws configure sso instead of static access keys. This is more secure for team environments because credentials rotate automatically. See How to Configure AWS SSO CLI Access for Linux Ubuntu for a full walkthrough.

Conclusion

You now have AWS CLI v2 installed and configured on Ubuntu 22.04. The same install process works for updating to newer versions — just re-download and run with --update.

With the CLI ready, you can start provisioning infrastructure. Check out How to Configure Terraform on WSL Ubuntu for AWS Provisioning if you want to manage AWS resources as code, or deploy your first EC2 instance directly from the console.