Cloud automation becomes painful when every S3 sync, IAM check, or EC2 lookup requires a trip through the AWS Console. The AWS Command Line Interface (AWS CLI) lets you run all of those operations directly from your terminal. This guide covers four installation methods for Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS, then walks through configuration, common commands, updates, troubleshooting, and removal.

Use the AWS official installer for AWS CLI v2 on any of the three supported releases. Snap is also AWS-published and handles automatic updates. The pip method covers legacy AWS CLI v1 inside a Python virtual environment. The Ubuntu package option applies only where its release-specific candidate fits your workflow.
Choose Your Installation Method
| Method | Version | Release Coverage | Updates | Best For |
|---|---|---|---|---|
| AWS official installer | AWS CLI v2 | Ubuntu 26.04, 24.04, 22.04 | Rerun installer with --update | Most users, servers, CI/CD, production |
| Snap package | AWS CLI v2 (v2/stable) | Ubuntu systems with snapd | Automatic Snap refresh | Users who want AWS-published auto-updates |
| pip virtual environment | AWS CLI v1 | Ubuntu 26.04, 24.04, 22.04 after python3-venv | Upgrade inside the virtual environment | Legacy scripts that require v1 |
| Ubuntu awscli package | Release-dependent | Available on 26.04 and 22.04; no candidate on 24.04 | APT upgrades | Only where the Ubuntu package version fits |
Pick one method. Every method places an aws command on your PATH, so mixing methods causes update and troubleshooting confusion.
Check the Ubuntu awscli Package First
Many users search for apt install awscli, but the available package differs by Ubuntu release. The table below shows what APT offers by default:
| Ubuntu Release | Default awscli Candidate | Guidance |
|---|---|---|
| Ubuntu 26.04 LTS | 2.31.x from universe | Works as an Ubuntu-packaged v2 option, but the AWS installer and Snap track AWS’s current v2 release more directly |
| Ubuntu 24.04 LTS | No package candidate | Use the AWS installer, Snap, or pip v1 virtual environment |
| Ubuntu 22.04 LTS | 1.22.x from universe | Provides old AWS CLI v1. Use the AWS installer or Snap if you need v2 |
If you deliberately choose the Ubuntu package on a supported release, install it with APT:
sudo apt install awscliOn minimal systems, the universe component may not be enabled. If APT cannot locate awscli or python3-venv, enable universe first:
sudo apt install software-properties-common -y
sudo add-apt-repository universe
sudo apt updateMethod 1: Install AWS CLI on Ubuntu 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, so the same command sequence works across all three supported Ubuntu LTS releases.
Step 1: Refresh APT metadata and install the required tools:
sudo apt update
sudo apt install curl unzip -yStep 2: Download the current x86_64 installer archive:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" \
-o "awscliv2.zip"ARM64 systems: Replace the URL above with
https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zipand download the matching.sigfile instead.
Step 3: Extract the archive and install AWS CLI:
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cliStep 4: Clean up the installer files:
rm -rf awscliv2.zip aws/Step 5: Confirm the installation:
aws --versionExpected output:
aws-cli/2.x.x Python/3.x.x Linux/7.0.0-14-generic exe/x86_64.ubuntu.26The exe/ segment confirms you are running the bundled AWS CLI v2 build from the official installer.
Method 2: Install AWS CLI v2 with Snap
Amazon Web Services publishes the AWS CLI directly on Snapcraft with classic confinement. Standard Ubuntu desktop and server installs include snapd by default. If snap is missing on a minimal system, install it first:
sudo apt install snapd -yInstall the v2/stable channel explicitly:
sudo snap install aws-cli --channel=v2/stable --classicImportant: Always specify
--channel=v2/stable. Thelatest/stableandv1/stablechannels can install AWS CLI v1 on some systems, which is the wrong major version for most workflows.
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.26If you need AWS CLI v1 from Snap for legacy compatibility, install the v1 channel:
sudo snap install aws-cli --channel=v1/stable --classicTo switch channels on an existing Snap install:
sudo snap refresh aws-cli --channel=v1/stableMethod 3: 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 v1 command behavior. A Python virtual environment avoids Ubuntu’s externally managed system Python restrictions on 24.04 and newer releases.
Do not confuse the official
awsclipackage on PyPI with the third-partyawscliv2wrapper. AWS publishes v2 through the official installer and Snap only.
Step 1: Install the virtual environment support package:
sudo apt install python3-venv -yStep 2: Create and activate a dedicated virtual environment:
python3 -m venv ~/.aws-cli-v1
source ~/.aws-cli-v1/bin/activateStep 3: Install AWS CLI v1 inside the environment:
pip install awscliStep 4: Verify the binary directly:
~/.aws-cli-v1/bin/aws --versionaws-cli/1.x.x Python/3.x.x Linux/7.0.0-14-generic botocore/1.x.xStep 5 (Optional): Add the virtual environment to your shell PATH so the v1 command runs without activating the environment each time. The guard prevents duplicate PATH entries 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 ~/.bashrcConfigure AWS CLI on Ubuntu
AWS CLI needs credentials and a default region before it can call AWS services. Access key data stores in ~/.aws/credentials, while region and output settings store in ~/.aws/config.
Configure with Access Keys
Start the interactive configuration wizard:
aws configureAWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: jsonReplace the example values with your real access key, secret key, default region, and preferred output format. Valid output formats are json, yaml, yaml-stream, text, and table.
Keep credentials out of shell history, Git repositories, screenshots, and shared terminal transcripts.
Configure with IAM Identity Center
If your organization uses AWS IAM Identity Center, configure SSO instead of long-lived access keys:
aws configure ssoAfter the profile exists, authenticate with:
aws sso login --profile productionReplace production with the profile name you created during setup.
Verify Your Configuration
List your active configuration values:
aws configure listNAME VALUE TYPE LOCATION
profile <not set> None None
access_key <not set> None None
secret_key <not set> None None
region <not set> None NoneValues 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"
}This command confirms that AWS CLI can sign requests and reach AWS with the active credentials.
Create Multiple Profiles
Use named profiles when you work with multiple AWS accounts, roles, or regions:
aws configure --profile productionRun commands against a specific profile with --profile:
aws sts get-caller-identity --profile productionTo set a default profile for all commands in the current shell session:
export AWS_PROFILE=productionUse 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.
List S3 Buckets
aws s3 lsWith valid credentials, this prints bucket names. No output means the account has no visible buckets.
Copy and Sync Files to S3
aws s3 cp localfile.txt s3://bucket-name/
aws s3 sync ./local-directory s3://bucket-name/remote-directoryThe sync command uploads changed files only, which makes it useful for backup scripts and static-site deployment workflows.
Inspect EC2 Instances
aws ec2 describe-instances
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --output tableThe first command returns detailed JSON. The second limits results to running instances and formats the output as a table.
Manage IAM Users
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/ReadOnlyAccessUse real user names and policy ARNs for your account.
Update AWS CLI on Ubuntu
Update AWS CLI with the same manager you used for installation. Confirm the active binary first with command -v aws.
Update the 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 --versionIf no newer version is available, the installer prints:
Found same AWS CLI version: /usr/local/aws-cli/v2/2.x.x. Skipping install.Update the Snap Method
sudo snap refresh aws-cli
aws --versionSnap also refreshes packages automatically in the background, so the manual refresh is mainly useful when you want to check immediately.
Update the pip v1 Method
~/.aws-cli-v1/bin/pip install --upgrade awscli
~/.aws-cli-v1/bin/aws --versionTroubleshoot AWS CLI on Ubuntu
Fix: aws Command Not Found
Check which aws binary your shell can find:
command -v awsFor the official installer, confirm the symlink points to the current AWS CLI v2 directory:
ls -l /usr/local/bin/awslrwxrwxrwx 1 root root 37 Apr 28 19:00 /usr/local/bin/aws -> /usr/local/aws-cli/v2/current/bin/awsIf the symlink is missing, rerun the official installer with the same --bin-dir and --install-dir paths.
or 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 in the installation steps above.
Fix: python3 venv ensurepip Error
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-v1Fix: 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:
Package awscli is not available, but is referred to by another package.
E: Package 'awscli' has no installation candidateUse the official installer or Snap for AWS CLI v2 on Ubuntu 24.04.
On Ubuntu 26.04 and 22.04, the package comes from universe. If APT cannot locate awscli or python3-venv, enable the universe repository and refresh:
sudo apt install software-properties-common -y
sudo add-apt-repository universe
sudo apt updateFix: Unable to Locate Credentials
AWS CLI prints this error when the active profile has no usable credentials:
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: 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-certificatesThen check time synchronization:
timedatectl status
sudo timedatectl set-ntp trueRemove AWS CLI from Ubuntu
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 Official Installer
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"Remove the Snap Package
sudo snap remove --purge aws-cli
hash -r
command -v aws || echo "aws removed"Remove the pip v1 Virtual Environment
rm -rf ~/.aws-cli-v1If you added the PATH line earlier, remove it from ~/.bashrc:
path_line='export PATH="$HOME/.aws-cli-v1/bin:$PATH"'
grep -vxF "$path_line" ~/.bashrc > ~/.bashrc.tmp
mv ~/.bashrc.tmp ~/.bashrc
source ~/.bashrcRemove the Ubuntu Package
sudo apt remove awscli
sudo apt autoremove --dry-runReview the dry-run output before confirming removals.
Remove AWS CLI Configuration Files
Back up ~/.aws/ before deleting it, because it holds saved profiles, regions, SSO settings, and credentials:
if [ -d ~/.aws ]; then
cp -r ~/.aws ~/.aws-backup
fi
rm -rf ~/.awsKeep the backup until you confirm you no longer need those profiles.
