How to Install AWS CLI on Ubuntu 26.04, 24.04 and 22.04

Install AWS CLI on Ubuntu 26.04, 24.04 and 22.04 via official installer, Snap, pip or wrapper. Covers setup, config, commands.

Last updatedAuthorJoshua JamesRead time8 minGuide typeUbuntu

Cloud automation gets awkward fast when every S3 sync, IAM check, or EC2 lookup has to go through the AWS Console. To install AWS CLI on Ubuntu, use AWS’s official v2 installer for the most consistent setup across Ubuntu 26.04, 24.04, and 22.04. Snap is also published by AWS and handles automatic updates, while pip is mainly useful when you specifically need the legacy AWS CLI v1 line inside a Python virtual environment.

This guide also covers the common sudo apt install awscli question. The Ubuntu package is release-dependent, so it is not the universal answer for current AWS CLI v2 on every supported Ubuntu LTS release.

Install AWS CLI on Ubuntu

Choose one installation method unless you intentionally need two versions for testing. Every method can place an aws command on your PATH, so mixing methods can make updates and troubleshooting confusing.

MethodVersion LineRelease CoverageUpdatesBest For
AWS official installerAWS CLI v2Ubuntu 26.04, 24.04, and 22.04Rerun installer with --updateMost users, servers, CI/CD, production systems
Snap packageAWS CLI v2 on v2/stable; v1 optionalUbuntu systems with snapdAutomatic Snap refreshUsers who want AWS-published packaging with automatic updates
pip virtual environmentAWS CLI v1Ubuntu 26.04, 24.04, and 22.04 after python3-venv is installedUpgrade inside the virtual environmentLegacy scripts or tooling that still requires AWS CLI v1
Ubuntu awscli packageRelease-dependentAvailable on 26.04 and 22.04; no candidate on 24.04APT upgradesOnly when the Ubuntu package version fits your release and workflow

These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. The official installer commands below use the x86_64 Linux archive. On ARM64 systems, download https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip and the matching .sig file instead.

Check the Ubuntu awscli Package

Readers often search for apt install awscli, but the package differs by Ubuntu release. Validation showed the following default candidates:

Ubuntu ReleaseDefault awscli CandidatePractical Guidance
Ubuntu 26.04 LTS2.31.x from universeWorks as an Ubuntu-packaged v2 option, but the AWS installer and Snap channel track AWS’s current v2 release more directly.
Ubuntu 24.04 LTSNo package candidateUse the AWS installer, Snap, or the pip v1 virtual environment method.
Ubuntu 22.04 LTS1.22.x from universeProvides old AWS CLI v1. Use the AWS installer or Snap if you need v2.

If you deliberately choose the Ubuntu package on a release where it exists, install it with APT:

sudo apt install awscli

Minimal systems may need Ubuntu’s universe component before that package or python3-venv appears. If APT cannot locate those packages, see how to enable Universe and Multiverse on Ubuntu, then run sudo apt update again.

Install AWS CLI v2 with the Official Installer

The official installer downloads AWS CLI v2 as a bundled Linux build. It does not depend on Ubuntu’s system Python version, which keeps the same command sequence working across supported Ubuntu LTS releases.

Refresh APT metadata and install the tools required to download and extract the archive:

sudo apt update
sudo apt install curl unzip -y

These commands require an account with sudo privileges. If your user cannot run administrative commands yet, follow the Ubuntu sudoers setup guide before continuing: add a user to sudoers on Ubuntu.

Download the current x86_64 installer archive from AWS:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

The curl command writes the archive to awscliv2.zip. AWS also publishes a matching signature file at https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip.sig; use the AWS install documentation’s PGP verification section if your deployment policy requires signature validation before installation.

Extract the archive and install AWS CLI under /usr/local/aws-cli, with command symlinks in /usr/local/bin:

unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli
You can now run: /usr/local/bin/aws --version

Remove the downloaded installer files from the same directory where you extracted them:

rm -rf awscliv2.zip aws/

Confirm that the installed command is active:

aws --version
aws-cli/2.x.x Python/3.x.x Linux/7.0.0-14-generic exe/x86_64.ubuntu.26

The exact AWS CLI, Python, and kernel values will change over time. The exe/ segment shows that you are running the bundled AWS CLI v2 build from the installer or Snap package.

Install AWS CLI v2 with Snap

The Snap package is published by Amazon Web Services on Snapcraft and uses classic confinement. Standard Ubuntu desktop and server installs usually include snapd already. If snap is missing on a minimal or customized system, install snapd first:

sudo apt install snapd -y

Install the AWS CLI v2 stable channel explicitly:

sudo snap install aws-cli --channel=v2/stable --classic
aws-cli (v2/stable) 2.x.x from Amazon Web Services (aws**) installed

Use the v2/stable channel when you specifically want AWS CLI v2. Current Snap metadata still exposes AWS CLI v1 on the latest/stable and v1/stable channels, so omitting the channel can install the wrong major version on some systems.

Verify the Snap path and version:

command -v aws
aws --version
/snap/bin/aws
aws-cli/2.x.x Python/3.x.x Linux/7.0.0-14-generic exe/x86_64.ubuntu.26

If you need AWS CLI v1 from Snap for legacy compatibility, install the v1 channel instead:

sudo snap install aws-cli --channel=v1/stable --classic

If AWS CLI is already installed through Snap, switch channels with snap refresh:

sudo snap refresh aws-cli --channel=v1/stable

Install AWS CLI v1 in a Python Virtual Environment

The pip package installs AWS CLI v1, not AWS CLI v2. Use this method only for legacy scripts or environments that still require the v1 command behavior. A virtual environment avoids Ubuntu’s externally managed system Python restrictions on 24.04 and newer releases.

Do not confuse the official awscli package on PyPI with the third-party awscliv2 wrapper. AWS publishes v2 directly through the official installer and Snap package, so this guide avoids wrapper packages that sit between your shell and AWS credentials.

Install the virtual environment support package:

sudo apt install python3-venv -y

Create and activate a dedicated Python virtual environment on Ubuntu for AWS CLI v1:

python3 -m venv ~/.aws-cli-v1
source ~/.aws-cli-v1/bin/activate

Install AWS CLI v1 inside that environment:

pip install awscli

Verify the virtual environment’s AWS CLI binary directly:

~/.aws-cli-v1/bin/aws --version
aws-cli/1.x.x Python/3.x.x Linux/7.0.0-14-generic botocore/1.x.x

Add the virtual environment to your shell path only if you want this v1 command to run without activating the environment each time. The guard prevents duplicate PATH lines if you rerun it:

touch ~/.bashrc
grep -qxF 'export PATH="$HOME/.aws-cli-v1/bin:$PATH"' ~/.bashrc || echo 'export PATH="$HOME/.aws-cli-v1/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Configure AWS CLI on Ubuntu

AWS CLI needs credentials and a default region before it can call AWS services. Access-key configuration is stored in ~/.aws/credentials, while region and output settings are stored in ~/.aws/config.

Configure AWS CLI Access Keys

Start the interactive configuration wizard:

aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: json

Replace the example values with your real AWS access key, secret key, default region, and preferred output format. Valid output formats include json, yaml, yaml-stream, text, and table.

Access keys should use the minimum permissions required for your task. Keep credentials out of shell history, Git repositories, screenshots, and shared terminal transcripts.

Configure AWS CLI IAM Identity Center

If your organization uses AWS IAM Identity Center, configure SSO instead of long-lived access keys:

aws configure sso

After the profile exists, authenticate with:

aws sso login --profile production

Replace production with the profile name you created. AWS documents the full configuration file layout in its AWS CLI configuration and credentials guide.

Verify AWS CLI Configuration

List your active configuration values:

aws configure list
NAME       : VALUE                    : TYPE             : LOCATION
profile    : <not set>                : None             : None
access_key : <not set>                : None             : None
secret_key : <not set>                : None             : None
region     : <not set>                : None             : None

Values of <not set> mean the current profile is incomplete. After credentials are configured, test the active identity:

aws sts get-caller-identity
{
    "UserId": "AIDACKCEVSQ6C2EXAMPLE",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/username"
}

Your account ID and ARN will be different. This command confirms that AWS CLI can sign requests and reach AWS with the active credentials.

Create Multiple AWS CLI Profiles

Use named profiles when you work with multiple AWS accounts, roles, or regions:

aws configure --profile production

Run commands against that profile with --profile:

aws sts get-caller-identity --profile production

Use AWS CLI on Ubuntu

After installation and configuration, AWS CLI commands work the same way across the official installer, Snap, pip v1, and Ubuntu package methods. The examples below cover common account, storage, and compute checks.

List S3 Buckets with AWS CLI

aws s3 ls

With valid credentials, the command prints bucket names or no output if the account has no visible buckets.

Copy and Sync Files to S3 with AWS CLI

aws s3 cp localfile.txt s3://bucket-name/
aws s3 sync ./local-directory s3://bucket-name/remote-directory

Replace bucket-name and paths with your own storage locations. The sync command uploads changed files only, which makes it useful for backup scripts and static-site deployment workflows.

Inspect EC2 Instances with AWS CLI

aws ec2 describe-instances
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --output table

The first command returns detailed JSON. The second command limits results to running instances and formats the output as a table.

Manage IAM Users with AWS CLI

aws iam list-users
aws iam create-user --user-name new-user
aws iam attach-user-policy --user-name new-user --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess

Use real user names and policy ARNs for your account. For the full command surface, refer to the AWS CLI Command Reference.

Update AWS CLI on Ubuntu

Update AWS CLI with the same manager you used for installation. Before troubleshooting an old version, confirm the active binary with command -v aws.

Update the AWS Official Installer Method

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
rm -rf awscliv2.zip aws/
aws --version
Found same AWS CLI version: /usr/local/aws-cli/v2/2.x.x. Skipping install.

If a newer version is available, the installer updates the existing files instead of printing the skip message.

Update the AWS CLI Snap Package

sudo snap refresh aws-cli
aws --version

Snap also refreshes packages automatically in the background, so the manual refresh command is mostly useful when you want to check immediately.

Update the pip AWS CLI v1 Method

~/.aws-cli-v1/bin/pip install --upgrade awscli
~/.aws-cli-v1/bin/aws --version

Troubleshoot AWS CLI on Ubuntu

Fix aws Command Not Found

First, check which aws command your shell can see:

command -v aws
/usr/local/bin/aws

For the official installer, confirm the symlink points to the current AWS CLI v2 directory:

ls -l /usr/local/bin/aws
lrwxrwxrwx 1 root root 37 Apr 28 19:00 /usr/local/bin/aws -> /usr/local/aws-cli/v2/current/bin/aws

If the symlink is missing, rerun the official installer with the same --bin-dir and --install-dir paths. For Snap installs, open a new login shell if /snap/bin/aws is not on your PATH. For pip v1 installs, run ~/.aws-cli-v1/bin/aws --version directly or add the virtual environment path as shown earlier.

Fix python3 venv ensurepip Errors

If python3 -m venv reports that ensurepip is unavailable, install the venv package and recreate the environment:

sudo apt install python3-venv -y
rm -rf ~/.aws-cli-v1
python3 -m venv ~/.aws-cli-v1

Fix Unable to Locate Package awscli

On Ubuntu 24.04, awscli has no default APT candidate, so sudo apt install awscli fails even when repositories are healthy. Use the official installer or Snap for AWS CLI v2 on that release.

Package awscli is not available, but is referred to by another package.
E: Package 'awscli' has no installation candidate

On Ubuntu 26.04 and 22.04, the package comes from universe. If APT cannot locate awscli or python3-venv on a release where it should exist, enable the Ubuntu Universe component and refresh package metadata.

sudo apt install software-properties-common -y
sudo add-apt-repository universe
sudo apt update

Fix AWS CLI Unable to Locate Credentials

AWS CLI prints this error when the active profile has no usable credentials:

AWS_EC2_METADATA_DISABLED=true aws s3 ls
aws: [ERROR]: An error occurred (NoCredentials): Unable to locate credentials. You can configure credentials by running "aws login".

Run aws configure for access keys, or use aws configure sso and aws sso login for IAM Identity Center profiles. Then rerun aws sts get-caller-identity to confirm the profile works.

Fix AWS CLI SSL Certificate Errors

Certificate failures usually point to missing CA certificates or an incorrect system clock. Refresh the CA package first:

sudo apt install ca-certificates -y
sudo update-ca-certificates
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

Then check time synchronization:

timedatectl status
sudo timedatectl set-ntp true

Remove AWS CLI from Ubuntu

Use the removal path that matches your installation method. AWS CLI credentials and profiles live under ~/.aws/ and are not removed by package, Snap, or installer cleanup unless you delete them separately.

Remove the AWS Official Installer Method

This removes the AWS CLI symlinks and the installer-managed directory under /usr/local. Verify the paths before running the commands if you customized --bin-dir or --install-dir.

sudo rm -f /usr/local/bin/aws /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
hash -r
command -v aws || echo "aws removed"
aws removed

Remove the AWS CLI Snap Package

sudo snap remove --purge aws-cli
hash -r
command -v aws || echo "aws removed"
aws-cli removed
aws removed

Remove the pip AWS CLI v1 Virtual Environment

This deletes the dedicated AWS CLI v1 virtual environment. Do not run it if you reused the same environment for other Python tools.

rm -rf ~/.aws-cli-v1

If you added the PATH line earlier, remove that exact line from ~/.bashrc:

path_line='export PATH="$HOME/.aws-cli-v1/bin:$PATH"'
grep -vxF "$path_line" ~/.bashrc > ~/.bashrc.tmp
mv ~/.bashrc.tmp ~/.bashrc
source ~/.bashrc

Remove the Ubuntu awscli Package

If you installed the release-dependent Ubuntu package, remove it with APT:

sudo apt remove awscli

Review any optional dependency cleanup separately before confirming removals:

sudo apt autoremove --dry-run

Remove AWS CLI Configuration Files

Delete ~/.aws/ only if you no longer need saved profiles, regions, SSO settings, or credentials.

if [ -d ~/.aws ]; then
    cp -r ~/.aws ~/.aws-backup
fi

This permanently deletes AWS CLI configuration and credential files for your user account. Keep the backup until you confirm you no longer need those profiles.

rm -rf ~/.aws

Conclusion

AWS CLI on Ubuntu is cleanest when the install source matches the job: the AWS installer for current v2 everywhere, Snap for AWS-published automatic updates, pip virtual environments for v1 compatibility, and the Ubuntu package only where its release-specific candidate fits. After installation, verify the active binary, configure credentials or SSO, and keep ~/.aws/ protected because it controls how the CLI signs requests against your AWS accounts.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show our tutorials more often in Top Stories and mark them as preferred in AI Mode and AI Overviews when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Add to the discussion

Questions, fixes, command output, and version notes help keep this guide current.

Verify before posting: