To install the AWS CLI on Ubuntu, use AWS’s own installer for version 2: download the zip, unzip it and run sudo ./aws/install. Then run aws configure to sign it in to your account. This works the same on Ubuntu 22.04, 24.04 and newer, and in Ubuntu on WSL. On Windows itself, see How to Install and Configure AWS CLI on Windows.
When I first wrote this post in 2021 I installed it with apt. That gave you version 1 of the CLI, which AWS no longer develops, and on recent Ubuntu releases the apt package is either missing or out of date, so use the installer below instead.
Install AWS CLI Version 2
# unzip is needed for the next step sudo apt update && sudo apt install -y unzip curl # download and install (x86_64; on ARM use awscli-exe-linux-aarch64.zip) curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install # check it aws --version
aws --version should print aws-cli/2. and a version number. To update it later, download the zip again and run sudo ./aws/install --update. AWS’s Install or update the AWS CLI page is the source for these commands.
These are from my 2021 install, with version 1 from apt:


Sign It In to Your Account
aws configure
It asks for an access key ID, the secret access key, a default region (for example eu-west-1) and an output format (json is fine). Access keys come from the IAM console. Treat them like a password: never commit them to a repository, and prefer short-lived sign-in with aws configure sso if your organisation uses IAM Identity Center.

Your answers are saved in 2 files in your home folder, ~/.aws/config and ~/.aws/credentials:

Check It Works
# which account and user you are signed in as aws sts get-caller-identity # list your S3 buckets whose names start with pw- aws s3api list-buckets --query "Buckets[].Name" --output text | tr '\t' '\n' | grep '^pw-'

get-caller-identity is the quickest test: if it returns your account number, the CLI is installed and signed in. Next steps are in How to Manage S3 Buckets with the AWS CLI and AWS CLI: List All IAM Users.
Related
If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.
Leave a Reply