AWS CLI Installation Guide on Ubuntu: Step-by-Step Tutorial

AWS CLI Installation Guide on Ubuntu: Step-by-Step Tutorial

The current way to install the AWS CLI v2 on Ubuntu is a single command:

curl -fsSL https://awscli.amazonaws.com/v2/install.sh | bashCode language: Bash (bash)

That is the install script AWS now recommends. It downloads, checks, and installs the CLI for the current user into ~/.local/share/aws-cli, then links the aws binary into ~/.local/bin. No sudo required.

Two other paths are officially supported. The zip installer puts the CLI system-wide under /usr/local and lets you pin an exact version. The snap package keeps itself up to date on desktop machines. Each one fails differently, and the failures are easy to avoid once you know which one you picked.

This guide covers all three, the verification steps, credentials setup, updates, removal, and the errors that actually show up on Ubuntu.

Check the prerequisites first

Ubuntu is supported on 64-bit releases. The CLI needs unzip, glibc, groff, and less; the last three ship by default on every desktop and server image you are likely to use. Verify before you start, so a missing utility does not look like a broken install:

lsb_release -a
unzip -v | head -n 1
ldd --version | head -n 1Code language: Bash (bash)

If unzip is missing on a minimal cloud image, install it:

sudo apt update && sudo apt install -y unzipCode language: Bash (bash)

One more thing to know before choosing a method: AWS maintains exactly one third-party package repository for Linux, and it is snap. Anything else that claims to carry the CLI, including apt and pip packages, is either the legacy v1 line or a community build that AWS does not guarantee to be current.

Method 1: the install script (recommended)

curl -fsSL https://awscli.amazonaws.com/v2/install.sh | bashCode language: Bash (bash)

The script works on both x86_64 and ARM, installs for the current user, and leaves your system directories untouched:

WhatWhere
CLI files~/.local/share/aws-cli
aws binary link~/.local/bin/aws
sudo neededno

The PATH trap. ~/.local/bin is not on PATH by default on Ubuntu. If you skip this step, the install succeeds and aws still returns command not found in a fresh shell:

export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcCode language: Bash (bash)

The installer prints a warning about this when the directory is not on your path. Read that output instead of jumping back to the download page.

Method 2: the zip installer (pin a version, or install system-wide)

Use this when you need a specific release, or when the CLI must be available to every user and every deployment script on the machine.

Intel and AMD (x86_64):

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/installCode language: Bash (bash)

ARM, including Graviton instances and ARM containers:

curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/installCode language: Bash (bash)

The installer writes files to /usr/local/aws-cli and creates the symlink at /usr/local/bin/aws. You can move both:

sudo ./aws/install --install-dir /opt/aws-cli --bin-dir /usr/local/binCode language: Bash (bash)

To upgrade an existing zip installation in place, add --update instead of removing the old one first:

sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --updateCode language: Bash (bash)

If you verify downloads in your pipeline, fetch the matching signature file next to the archive and check it before running the installer:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip.sig" -o "awscliv2.sig"
gpg --verify awscliv2.sig awscliv2.zipCode language: Bash (bash)

AWS publishes the public key used for these signatures on the same install page. Import it once, then the verification runs offline.

Method 3: snap

sudo snap install aws-cli --classicCode language: Bash (bash)

Snap refreshes the CLI automatically, which is convenient on a workstation and inconvenient on a build agent where you need reproducible versions: there is no support for selecting a minor version, only channels. If your team pins tool versions, use the zip installer instead.

Which method should you pick?

MethodInstalls tosudoPin an exact versionUpdates
Install script~/.local (current user)nonoaws update
Zip installer/usr/local (all users)yesyesaws update, or re-run with --update
Snapsnap sandboxyesno, channels onlyautomatic

Short recommendation: on a developer laptop or a single-user server, take the install script and fix PATH once. On anything that provisions machines or runs CI, take the zip installer so the version in the image is the version you tested.

Verify the installation

aws --version
# aws-cli/2.27.41 Python/3.11.6 Linux/5.10.205 x86_64

command -v awsCode language: Bash (bash)

The output must start with aws-cli/2. If it starts with aws-cli/1., you are running the legacy v1 that came from apt, pip, or yum, and the shell is finding it before your v2 installation. Remove the old one and check which binary wins:

command -v -a aws
sudo apt remove awscliCode language: Bash (bash)

Configure credentials

aws configure
# AWS Access Key ID [None]:
# AWS Secret Access Key [None]:
# Default region name [None]: eu-central-1
# Default output format [None]: jsonCode language: Bash (bash)

The values land in two files:

  • ~/.aws/credentials – access key ID and secret access key, per profile;
  • ~/.aws/config – region, output format, and per-profile settings such as a role to assume.

Both files are split into sections, so a second account is just a named profile: aws configure --profile staging, then aws --profile staging s3 ls.

Check what the CLI will actually use, and where each value came from:

aws configure list
aws sts get-caller-identityCode language: Bash (bash)

aws configure list marks each value as coming from a file, an environment variable, or nowhere. That matters, because AWS_ACCESS_KEY_ID, AWS_PROFILE, and AWS_REGION in your shell override the files and are the usual reason a command hits the wrong account.

For account hygiene, the key you paste here should belong to an IAM user or role with the permissions the job needs, not to the root account. If you are winding an account down instead of setting one up, the checks in our guide to closing an AWS account safely cover the same inventory work from the other direction. For organizations, aws configure sso replaces long-term keys with short-lived credentials and is worth the extra setup.

Update and remove the CLI

Installations made with the install script or an official installer update in place:

aws updateCode language: Bash (bash)

If the CLI was installed for all users, run it with sudo. Snap installations refresh on their own, or on demand:

sudo snap refresh aws-cliCode language: Bash (bash)

Removing depends on the method used:

# install script, current user
rm -rf ~/.local/share/aws-cli ~/.local/bin/aws

# zip installer, system-wide
sudo rm -rf /usr/local/aws-cli /usr/local/bin/aws

# snap
sudo snap remove aws-cliCode language: Bash (bash)

Troubleshooting

SymptomLikely causeFix
aws: command not found right after a successful install~/.local/bin is not on PATHAdd it to ~/.bashrc and open a new shell
aws --version reports 1.xLegacy v1 from apt, pip, or yum is earlier in PATHcommand -v -a aws, then remove the v1 package
unzip: command not foundMinimal cloud image without unzipsudo apt install unzip
version 'GLIBC_2.xx' not foundUbuntu release older than the build targetUpgrade the distribution, or build from source
Install worked in one terminal, not in anotherPATH exported in the shell instead of the rc filePut the export in ~/.bashrc or ~/.profile
Unable to locate credentialsNo profile configured, or the wrong one is activeaws configure, or set AWS_PROFILE
Commands hit the wrong account or regionEnvironment variables shadowing the filesaws configure list shows the source of each value
Two aws binaries, confusing behaviourSnap and a zip install on the same machinecommand -v -a aws, keep one, remove the other

What to do next

With the CLI working and credentials in place, the useful next step is choosing what to automate rather than installing more tools. AWS Services Explained for Developers maps the services you will touch first, and Essential AWS Features for DevOps Engineers covers the ones that matter for day-to-day operations. If you also deploy to Google Cloud, the same install decision exists there, and Install Google Cloud CLI on Linux and Windows follows the same structure. For teams weighing both providers, AWS vs GCP Services Comparison puts the service names side by side.

Sources

FAQ

These answers cover the install decisions that cause the most trouble on Ubuntu: which repository is official, when sudo is required, how updates reach an existing install, where credentials live, and whether ARM machines need a different package.

Is the AWS CLI available in the Ubuntu apt repository?

Not as an AWS-maintained package. AWS documents snap as the only third-party repository it supports, and warns that other repositories cannot be guaranteed to carry the latest version. Anything shipped through apt or pip on Ubuntu is either the legacy v1 line or a community build, so install v2 from the official install script, the zip installer, or snap.

Do I need sudo to install the AWS CLI v2 on Ubuntu?

It depends on the method. The install script (`curl -fsSL https://awscli.amazonaws.com/v2/install.sh | bash`) installs for the current user into `~/.local/share/aws-cli` and needs no sudo. The zip installer writes to `/usr/local/aws-cli` with a symlink in `/usr/local/bin`, so it needs sudo. The snap package also needs sudo.

How do I update the AWS CLI without reinstalling it manually?

Run `aws update`. AWS documents it for installations made with the install script or an official installer, and it preserves whether the CLI was installed for all users or the current user. If the installation is all-users, run `aws update` with sudo. A snap installation updates itself and can be forced with `sudo snap refresh aws-cli`.

Where does the AWS CLI store credentials and configuration?

Long-term credentials go to `~/.aws/credentials` and settings such as region and output format go to `~/.aws/config`, both split into named profiles. `aws configure list` shows which profile, access key, region, and output format are in effect, and marks where each value came from, which is how you catch environment variables shadowing your files.

Does AWS CLI v2 work on ARM Ubuntu, or only on x86_64?

It works on both. AWS publishes a separate Linux ARM build at `https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip`, and the install script detects the architecture on its own. ARM instances, Graviton servers, and Docker on Apple Silicon hosts all use the aarch64 path.

Nathan Cole Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *