How to Install AWS CLI on Ubuntu

Install AWS CLI on Ubuntu with the official v2 Linux installer (recommended), sudo apt install awscli from universe, or the Amazon Snap. Configure with aws configure, verify with aws --version and aws sts get-caller-identity, update v2, and fix PATH conflicts between /usr/local/bin and /usr/bin.

Published

Updated

Read time 7 min read

Reviewed byDeepak Prasad

Install AWS CLI on Ubuntu banner with aws --version terminal output and AWS orange accent

The AWS Command Line Interface (AWS CLI) is how you create EC2 instances, upload to S3, manage IAM users, and automate cloud work from a terminal—without clicking through the AWS Management Console for every step. On Ubuntu you can install it from Amazon’s official v2 bundle, from apt in universe, or from the Snap store.

This guide shows how to install AWS CLI on Ubuntu the way I run it on cloud VMs and local workstations: official v2 installer when I want the newest build, apt install awscli when I want distribution packaging, and Snap when auto-updates matter. You will configure credentials with aws configure, verify with aws sts get-caller-identity, and learn what to do when which aws points at the wrong binary.

Tested on: Ubuntu 25.04 (Plucky Puffin); kernel 6.14.0-37-generic; amd64.

IMPORTANT
AWS CLI v1 and v2 both install a command named aws. Keep one primary install on your PATH. If you previously used pip install awscli (v1), remove it before installing v2, or expect confusing aws --version output—see AWS migration guide.

Quick command summary

Task Command
Check if aws exists command -v aws
Inspect apt candidate apt-cache policy awscli
Install v2 (official, recommended) curl zip → unzipsudo ./aws/install
Install from Ubuntu universe sudo apt update && sudo apt install -y awscli
Install Snap (Amazon) sudo snap install aws-cli --classic
Verify version aws --version
Configure credentials aws configure
Test identity aws sts get-caller-identity
Update official v2 Re-download zip → sudo ./aws/install … --update
Remove official v2 sudo rm -rf /usr/local/aws-cli /usr/local/bin/aws

Prerequisites

  • Ubuntu 22.04 LTS, 24.04 LTS, or newer (25.04 tested here) on x86_64 for the commands below. ARM64 hosts need the aarch64 installer zip instead.
  • sudo for system-wide installs.
  • curl and unzip for the official bundle (sudo apt install -y curl unzip).
  • Outbound HTTPS to awscli.amazonaws.com and your AWS API endpoints.
  • For aws configure: an IAM access key or SSO profile (see AWS CLI tutorial for creating keys and first EC2/S3 commands).

What you are installing

Method Binary location Version line (tested) Best for
Official v2 installer /usr/local/bin/aws aws-cli/2.35.11exe/x86_64 Latest features, teams that pin upstream builds
apt install awscli /usr/bin/aws aws-cli/2.23.6source/x86_64 Ubuntu-supported updates via apt
Snap aws-cli /snap/bin/aws Tracks Amazon channels Hands-off updates (--classic)

On Ubuntu 25.04, awscli in universe is AWS CLI v2—not the old v1 Python package from a few years ago. The official bundle still ships newer point releases than apt at the time of writing.


Amazon’s supported path for AWS CLI v2 on Linux is a self-contained installer you download with curl. I use this on bastion hosts and CI images when I want the same version AWS documents in getting started install.

Install dependencies:

bash
sudo apt update
sudo apt install -y curl unzip

Download, extract, and install:

bash
cd /tmp
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
unzip -q awscliv2.zip
sudo ./aws/install

Near the end of the install you should see:

text
You can now run: /usr/local/bin/aws --version

Confirm:

bash
aws --version
which aws

On my Ubuntu 25.04 host that printed:

text
aws-cli/2.35.11 Python/3.14.5 Linux/6.14.0-37-generic exe/x86_64.ubuntu.25
/usr/local/bin/aws

The exe/ segment means you are running the bundled v2 binary, not the distro Python build.

HINT
AWS documents optional GPG signature verification on the zip before install. For production golden images, follow verify the download in the official guide.

Update an existing official v2 install

Re-download the zip, extract, and pass --update:

bash
cd /tmp
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
unzip -qo awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

Method 2: Install AWS CLI from apt (universe)

When you want Ubuntu-packaged AWS CLI and routine apt upgrade updates, install awscli from universe:

bash
sudo apt update
sudo apt install -y awscli

Check the candidate before you install:

bash
apt-cache policy awscli

On Ubuntu 25.04 I saw:

text
awscli:
  Installed: (not installed)
  Candidate: 2.23.6-1
  Version table:
     2.23.6-1 500
        500 http://archive.ubuntu.com/ubuntu plucky/universe amd64 Packages

After apt install, verify:

bash
/usr/bin/aws --version
text
aws-cli/2.23.6 Python/3.13.3 Linux/6.14.0-37-generic source/x86_64.ubuntu.25
NOTE
Amazon does not maintain third-party apt repositories; Ubuntu’s version can lag the official installer. That is fine for many servers—use Method 1 when release notes list a feature you need today.

If you already installed the official bundle, which aws may still show /usr/local/bin/aws because that path sorts earlier on PATH. Use type -a aws to see every copy.


Method 3: Install AWS CLI from Snap

Amazon publishes aws-cli on Snapcraft. Classic confinement avoids sandbox issues with credential files and shell completion:

bash
sudo snap install aws-cli --classic

Confirm:

bash
/snap/bin/aws --version

Snap refreshes automatically unless you pinned a channel. For v1 compatibility (legacy scripts only), Amazon documents snap install aws-cli --channel=v1/stable --classic—prefer v2 for new work.

WARNING
Do not install official v2 + apt + Snap on the same machine without a deliberate PATH strategy. Automation and cron jobs often invoke the first aws on PATH, not the one you tested interactively.

Configure AWS CLI on Ubuntu

After install, wire credentials and a default Region. Interactive setup:

bash
aws configure

You will be prompted for:

  • AWS Access Key ID and Secret Access Key (from IAM → Users → Security credentials), or leave blank when using SSO profiles later.
  • Default region name (for example us-east-1 or ap-south-1).
  • Default output format (json, yaml, text, or table—press Enter for JSON).

Files are written under ~/.aws/credentials and ~/.aws/config.

Test that credentials work:

bash
aws sts get-caller-identity

With valid keys you get JSON containing Account, UserId, and Arn. Without credentials you see Unable to locate credentials—install succeeded; configuration is the next step.

For hands-on EC2 and S3 examples after configure, continue with AWS CLI explained with practical examples. Building a cluster on EC2 also assumes a working CLI—see setup Kubernetes on AWS EC2.

WARNING
Never commit access keys to git or paste them in shell history on shared machines. On EC2, prefer IAM instance profiles over long-lived access keys.

Daily checks and shell completion

Task Command
List S3 buckets (smoke test) aws s3 ls
Region in config aws configure get region
CLI help aws help
Service help aws s3 help

Enable bash completion for the official install (optional):

bash
echo 'complete -C /usr/local/bin/aws_completer aws' >> ~/.bashrc

Adjust the path if you installed only via apt (/usr/bin/aws_completer when present).


Uninstall

Official v2 bundle:

bash
sudo rm -rf /usr/local/aws-cli /usr/local/bin/aws /usr/local/bin/aws_completer
hash -r

APT:

bash
sudo apt purge -y awscli
sudo apt autoremove -y

Snap:

bash
sudo snap remove aws-cli

Remove ~/.aws only when you no longer need stored profiles.


Troubleshooting

Symptom Likely cause Fix
aws: command not found Not installed or PATH missing /usr/local/bin Install via Method 1 or 2; open a new shell; command -v aws
aws --version shows old 1.x Legacy pip v1 or mixed installs pip3 uninstall awscli; remove duplicate binaries; reinstall v2 only
which aws ≠ expected path Multiple installs type -a aws; remove one method or call full path
Unable to locate credentials aws configure not run Run aws configure or set AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_DEFAULT_REGION
unzip: command not found Missing unzip sudo apt install -y unzip
curl: (6) Could not resolve host DNS or offline host Fix networking; verify curl -fsSL https://awscli.amazonaws.com/…
apt awscli not found Universe disabled Enable universe in Software & Updates; sudo apt update
Permission denied on ./aws/install Extract failed or wrong directory cd into folder containing aws/install; chmod +x aws/install
Snap aws vs /usr/local/bin/aws differ Parallel installs Pick one package manager; adjust PATH for scripts

References


Summary

The reliable way to install AWS CLI on Ubuntu for most production and dev machines is Amazon’s official v2 Linux installer: download awscli-exe-linux-x86_64.zip, run sudo ./aws/install, and confirm aws-cli/2.x with exe/ in aws --version. Use sudo apt install awscli when you want Ubuntu universe packaging (v2 on current releases, but often behind the official bundle). Snap aws-cli --classic is a valid choice when you want Amazon-maintained auto-updates.

After install, run aws configure, then aws sts get-caller-identity before you script against live accounts. If versions disagree, type -a aws almost always reveals a second install shadowing the one you thought you were using.

Frequently Asked Questions

1. How do I install AWS CLI on Ubuntu?

Download the official AWS CLI v2 Linux x86_64 zip with curl, unzip it, and run sudo ./aws/install. That places /usr/local/bin/aws on your PATH. Alternatively use sudo apt install awscli from universe (AWS CLI v2 on current Ubuntu) or sudo snap install aws-cli --classic for Amazon official Snap builds.

2. What is the difference between AWS CLI v1 and v2 on Ubuntu?

AWS CLI v2 is the current supported line with bundled binaries, improved pagination, and SSO support. v1 (legacy Python awscli via pip) is in maintenance mode. Both use the aws command name—only one should be on your PATH. aws --version shows aws-cli/2.x for v2 or aws-cli/1.x for v1.

3. Should I use apt or the official installer for AWS CLI on Ubuntu?

Use the official v2 installer when you need the latest release (for example 2.35.x) or pin a specific build. Use sudo apt install awscli when you want Ubuntu-supported updates through apt—on 25.04 universe ships aws-cli/2.23.6. Avoid mixing both without understanding PATH order (/usr/local/bin usually wins).

4. How do I install AWS CLI v2 on Ubuntu 22.04 or 24.04 LTS?

The same official installer works on 22.04, 24.04, and 25.04 amd64: curl the awscli-exe-linux-x86_64.zip, unzip, sudo ./aws/install. On ARM64 Graviton instances use the aarch64 zip from AWS docs. Enable universe and apt install awscli if you prefer packages—version may lag the official bundle.

5. How do I configure AWS CLI after installing on Ubuntu?

Run aws configure and enter your Access Key ID, Secret Access Key, default region (for example us-east-1), and output format (json is typical). Credentials land in ~/.aws/credentials and ~/.aws/config. Test with aws sts get-caller-identity when keys are valid. Prefer IAM roles on EC2 instead of long-lived keys when possible.

6. How do I update AWS CLI v2 on Ubuntu?

Re-download the latest zip and run sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update from the extracted aws folder. For apt installs use sudo apt update && sudo apt upgrade awscli. Snap users get automatic refreshes from the aws-cli snap unless you pinned a channel.

7. How do I uninstall AWS CLI from Ubuntu?

Official v2: sudo rm -rf /usr/local/aws-cli /usr/local/bin/aws /usr/local/bin/aws_completer. Apt: sudo apt purge -y awscli. Snap: sudo snap remove aws-cli. Remove ~/.aws only when you no longer need saved credentials.

8. Why does aws --version show the wrong version on Ubuntu?

Multiple installs share the aws name. Run which -a aws and type -a aws—/usr/local/bin/aws (official v2 bundle) often precedes /usr/bin/aws (apt). Remove or reprioritize the install you do not want, or call the full path explicitly.

9. Is AWS CLI available as a Snap on Ubuntu?

Yes. Amazon publishes aws-cli on Snapcraft. Install with sudo snap install aws-cli --classic for v2 auto-updates. Classic confinement avoids sandbox issues with credential files and plugins. Pin channels only when your team requires a fixed minor version.

10. How do I fix aws command not found on Ubuntu?

The CLI is not installed or /usr/local/bin is missing from PATH. Install with the official bundle or apt, then run hash -r and open a new shell. Confirm with command -v aws. For login shells, ensure /usr/local/bin appears in PATH before relying on scripts in cron or systemd units.
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive …