How to install and configure AWS CLI
The official AWS installer is the only method I recommend for CLI v2. It stays up to date, doesn’t conflict with system packages, and works the same way on every machine.
Install AWS CLI v2
Pick your OS. All methods install the same AWS CLI v2 binary.
macOS
Install via the official pkg installer:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
rm AWSCLIV2.pkg
Or if you prefer Homebrew:
brew install awscli
Windows
Download and run the MSI installer:
Download awscli.amazonaws.com/AWSCLIV2.msi and run it. The installer adds aws to your PATH automatically.
Or install via winget:
winget install Amazon.AWSCLI
Or via Chocolatey:
choco install awscli
Ubuntu / Debian
Download the zip installer and run it:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf aws awscliv2.zip
Skip snap install and pip install. They fall behind on updates and can conflict with system Python.
RHEL / Amazon Linux
Same zip installer as Ubuntu:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf aws awscliv2.zip
Amazon Linux 2023 comes with AWS CLI v2 preinstalled. Check with aws --version before installing.
Verify it worked on any OS:
aws --version
You should see something like aws-cli/2.27.x. If you get “command not found,” the binary isn’t in your PATH.
Configure credentials
Run the configure command and enter your Access Key ID and Secret Access Key. If you don’t have these yet, create them in the IAM console under your user’s Security credentials tab.
aws configure
AWS Access Key ID [None]: AKIA...
AWS Secret Access Key [None]: wJal...
Default region name [None]: ap-south-1
Default output format [None]: json
I use ap-south-1 (Mumbai) for most of my work, but pick whatever region is closest to your users.
Verify the setup
Check that the CLI is authenticated:
aws sts get-caller-identity
{
"UserId": "AIDA...",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/your-username"
}
If that returns your account details, you’re good. The CLI is installed and authenticated.
Updating later
Run the same installer with --update when a new version comes out:
macOS
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
rm AWSCLIV2.pkg
Windows
Download and run the latest MSI from awscli.amazonaws.com/AWSCLIV2.msi. It overwrites the previous version.
Ubuntu / Debian
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
rm -rf aws awscliv2.zip
RHEL / Amazon Linux
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
rm -rf aws awscliv2.zip