AWS CLI lets you manage AWS services from the terminal so you can script deployments, sync data to S3, inspect CloudWatch logs, and manage IAM users without leaving the shell. By the end, you will have AWS CLI installed on Ubuntu, configured with credentials, and verified with real commands.
Choose Your AWS CLI Installation Method
Ubuntu offers four practical installation paths for AWS CLI. The official installer delivers AWS CLI v2 as a pre-built package that AWS maintains. Snap provides automatic updates and can install either v2 or v1 depending on the channel you choose. The pip method installs AWS CLI v1 through Python’s package manager for legacy compatibility. The awscliv2 wrapper delivers AWS CLI v2 through pip using Docker or downloaded binaries, but it is a third-party tool not maintained by AWS.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Official Installer | AWS Official | v2 (latest) | Manual via script | Production systems, CI/CD pipelines |
| Snap (v2/stable) | Snapcraft | v2 (current) | Automatic | Desktop users who want auto-updates |
| pip | PyPI | v1 (legacy) | pip upgrade | Legacy compatibility, virtual environments |
| awscliv2 wrapper | PyPI (unofficial) | v2 (via wrapper) | pip upgrade | Docker-first workflows, Python integration |
For most users, the official installer is recommended because it provides the current AWS CLI v2 release that AWS directly maintains, includes all features, and works independently of system Python versions.
These steps cover Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS. The official installer and Snap methods use the same commands on each release. Ubuntu 24.04 and 26.04 enforce externally managed Python environments, so system-wide pip installs require
--break-system-packages; Ubuntu 22.04 uses pip without that flag. The virtual environment method works on all supported releases without--break-system-packages. If you use pip, follow the version-specific instructions in Method 3.
Method 1: Install AWS CLI via Official Installer
The official installer provides AWS CLI v2 as a pre-built binary package. This method works independently of your system’s Python installation and receives direct support from AWS.
Install Required Dependencies
Install the required tools for downloading and extracting the installer:
sudo apt install curl unzip -y
The curl package downloads the installer archive, while unzip extracts it. The -y flag accepts the prompt automatically; remove it if you want to review the package list.
Download the AWS CLI Installer
Download the latest AWS CLI v2 installer for Linux:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
The curl command shows progress during download, and the -o flag specifies the output filename.
These commands use the x86_64 installer. Check your architecture with
uname -m. If you seeaarch64, downloadhttps://awscli.amazonaws.com/awscli-exe-linux-aarch64.zipinstead.
Extract and Run the Installer
Extract the installer archive and run the installation script:
unzip awscliv2.zip
sudo ./aws/install
The installer places AWS CLI binaries in /usr/local/aws-cli and creates a symlink at /usr/local/bin/aws. You should see confirmation output:
You can now run: /usr/local/bin/aws --version
Clean up the downloaded files:
rm -rf awscliv2.zip aws/
Verify Installation
Confirm that AWS CLI is installed and accessible:
aws --version
You should see output showing the installed version:
aws-cli/2.32.32 Python/3.13.11 Linux/6.6.87.2-microsoft-standard-WSL2 exe/x86_64.ubuntu.26
Your version number and kernel string will differ based on the release date and your system. The trailing exe/ portion confirms the official installer build.
Method 2: Install AWS CLI via Snap
Snap packages update automatically. Ubuntu includes snapd by default on standard desktop and server installs. If snap is missing (minimal installs, containers, WSL), install snapd first:
sudo apt install snapd -y
Install AWS CLI v2 from Snap Store
Install AWS CLI v2 from the v2 channel:
sudo snap install aws-cli --channel=v2/stable --classic
The --classic flag grants full system access so AWS CLI can read configuration files in your home directory. The Snap Store stable channel tracks AWS CLI v1, so use v2/stable for v2.
Verify Installation
Confirm that AWS CLI is working correctly:
aws --version
The output format matches the Method 1 example, and Snap installs end with snap/ in the trailing platform string.
Install AWS CLI v1 via Snap (Optional)
If you need AWS CLI v1 for compatibility with legacy systems or scripts, install the v1 channel:
sudo snap install aws-cli --channel=v1/stable --classic
If you already installed v2, switch channels with:
sudo snap refresh aws-cli --channel=v1/stable
Snap uses one channel at a time, so choose the version that matches your requirements.
Method 3: Install AWS CLI via pip
The pip method installs AWS CLI v1 through Python’s package manager. This approach works well when you need the older AWS CLI version or prefer managing it alongside other Python tools. Using a virtual environment provides the cleanest installation that avoids system conflicts and works identically across all Ubuntu versions.
Install Prerequisites
Ensure pip is available:
sudo apt install python3-pip python3-venv -y
Ubuntu includes Python 3 by default, but pip and venv require separate installation. This command adds both packages for virtual environment support.
Install in Virtual Environment (Recommended)
Create a dedicated virtual environment for AWS CLI:
python3 -m venv ~/.aws-venv
This creates an isolated Python environment in your home directory. Virtual environments prevent conflicts with system packages and work identically across Ubuntu 22.04, 24.04, and 26.04 without needing version-specific flags.
Activate the virtual environment:
source ~/.aws-venv/bin/activate
Your prompt changes to show (aws-venv), indicating the virtual environment is active. While active, Python commands use the isolated environment rather than system packages.
Install AWS CLI in the virtual environment:
pip install awscli
This installs AWS CLI v1 in the isolated environment. No --break-system-packages flag needed, and the installation won’t conflict with system Python packages.
When you want to run AWS CLI, activate the environment and run it:
source ~/.aws-venv/bin/activate
aws --version
If you want AWS CLI available without activating the environment each time, add the venv bin directory to your PATH:
echo 'export PATH="$HOME/.aws-venv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
This keeps the virtual environment binaries on your PATH without touching system Python packages.
Install System-Wide (Alternative)
If you prefer system-wide installation, commands differ by Ubuntu version due to Python environment protections.
For Ubuntu 24.04 LTS and 26.04 LTS:
python3 -m pip install --break-system-packages awscli
Ubuntu 24.04 and 26.04 implement PEP 668, which prevents system-wide pip installations to avoid conflicts with APT-managed packages. The --break-system-packages flag bypasses this protection. Use this only when you understand the risks of potential package conflicts.
For Ubuntu 22.04 LTS:
python3 -m pip install awscli
Ubuntu 22.04 allows system-wide pip installations without additional flags.
Verify Installation
Check the installed version. If you used the virtual environment, activate it first or run ~/.aws-venv/bin/aws directly:
source ~/.aws-venv/bin/activate
aws --version
Expected output varies by Ubuntu version due to different Python releases:
Ubuntu 22.04: aws-cli/1.44.15 Python/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2 botocore/1.42.25 Ubuntu 24.04: aws-cli/1.44.15 Python/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2 botocore/1.42.25 Ubuntu 26.04: aws-cli/1.44.15 Python/3.13.11 Linux/6.6.87.2-microsoft-standard-WSL2 botocore/1.42.25
The pip method installs AWS CLI v1 (1.x series), not the current v2 release. Your kernel string will differ. If you need v2 features, use the official installer or Snap method instead.
Method 4: Install AWS CLI v2 via awscliv2 Wrapper
The awscliv2 package provides a Python wrapper that runs AWS CLI v2 either through Docker containers or by downloading official binaries. This method works when you need AWS CLI v2 in Python environments or prefer pip-based management, but it’s maintained by a third party, not AWS.
The awscliv2 package is not officially maintained by AWS. It’s a community wrapper project that uses Docker by default or downloads AWS binaries when you run the install command. Review the source code and understand the security implications before using third-party tools with AWS credentials. For production systems, prefer the official installer (Method 1) which AWS maintains directly.
Install Prerequisites
Ensure pip and venv are available:
sudo apt install python3-pip python3-venv -y
If you plan to use the Docker-based execution (default behavior), install Docker:
sudo apt install docker.io -y
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
Log out and back in for the group change to take effect. You can skip Docker and install AWS CLI v2 binaries directly with the wrapper if you prefer local execution.
Docker mode runs AWS CLI inside the
amazon/aws-clicontainer as root. Files created in your current directory may be owned by root on the host. Useawsv2 --installif you want local binaries and normal file ownership.
Install in Virtual Environment (Recommended)
Create a virtual environment for the wrapper:
python3 -m venv ~/.awsv2-venv
source ~/.awsv2-venv/bin/activate
pip install awscliv2
This installs the awscliv2 wrapper in an isolated environment without system package conflicts. The wrapper installs as awsv2 command.
If you want awsv2 available without activating the environment each time, add the venv bin directory to your PATH:
echo 'export PATH="$HOME/.awsv2-venv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
This exposes the wrapper without touching system Python packages.
Install System-Wide (Alternative)
For system-wide installation, commands differ by Ubuntu version.
For Ubuntu 24.04 LTS and 26.04 LTS:
python3 -m pip install --break-system-packages awscliv2
For Ubuntu 22.04 LTS:
python3 -m pip install awscliv2
Install AWS CLI v2 Binaries (Optional)
By default, awscliv2 uses Docker to run AWS CLI commands. To download and use native AWS CLI v2 binaries instead:
If you installed the wrapper in a virtual environment and did not add it to your PATH, run
~/.awsv2-venv/bin/awsv2 --installinstead.
awsv2 --install
This downloads the official AWS CLI v2 installer and installs binaries in ~/.awscliv2 with executables under ~/.awscliv2/binaries. The wrapper then uses these local binaries instead of Docker.
Verify Installation
After running awsv2 --install, check the wrapper version and AWS CLI version. If you installed in a virtual environment, activate it first or run ~/.awsv2-venv/bin/awsv2 directly:
~/.awsv2-venv/bin/awsv2 --version
2.3.1 AWS CLI v2 command: /home/ubuntu/.awscliv2/binaries/aws aws-cli/2.32.32 Python/3.13.11 Linux/6.6.87.2-microsoft-standard-WSL2 exe/x86_64.ubuntu.26
Your home path and kernel string will differ. If you did not run --install, the wrapper will attempt to use Docker and may pull the amazon/aws-cli image on first run.
Configure AWS CLI
AWS CLI requires credentials and default settings before it can interact with your AWS account. Configuration is stored in ~/.aws/config (region and output preferences) and ~/.aws/credentials (access keys). This setup works identically regardless of installation method.
Quick Configuration
Start the interactive configuration wizard:
aws configure
Provide four configuration values when prompted:
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 credentials with your actual AWS access key ID and secret access key. For the region, choose the AWS region closest to your location or where your resources reside. Valid output formats include json, yaml, yaml-stream, text, and table.
To create AWS access keys, log into the AWS Console, navigate to IAM > Users > Security credentials > Create access key. Follow AWS best practices by creating keys with the minimum required permissions and enabling MFA for your account. Never share or commit access keys to version control.
Verify Configuration
Test your configuration by listing your S3 buckets:
aws s3 ls
If credentials are missing, AWS CLI reports:
Unable to locate credentials. You can configure credentials by running "aws login".
Use aws configure for access keys, or aws sso login if you use AWS SSO. With valid credentials, the command prints bucket names or no output if you have no buckets.
Check your current configuration details:
aws configure list
NAME : VALUE : TYPE : LOCATION profile : <not set> : None : None access_key : ****************3456 : shared-credentials-file : secret_key : ****************EKEY : shared-credentials-file : region : us-east-1 : config-file : ~/.aws/config
This output confirms which credentials and region AWS CLI will use for commands.
Multiple Profiles
AWS CLI supports multiple named profiles for managing different AWS accounts or roles. Add a new profile:
aws configure --profile production
This creates a separate configuration under the production profile name. Use profiles with the --profile flag:
aws s3 ls --profile production
Commands without --profile use the default profile automatically.
Common AWS CLI Commands
These examples demonstrate practical AWS CLI operations for everyday tasks. Commands work identically across all installation methods and Ubuntu versions once credentials are configured.
S3 Operations
List all S3 buckets in your account:
aws s3 ls
Upload a file to an S3 bucket:
aws s3 cp localfile.txt s3://bucket-name/
Sync a local directory to S3:
aws s3 sync ./local-directory s3://bucket-name/remote-directory
The sync command efficiently uploads only changed files, making it useful for backup scripts and static site deployments.
EC2 Instance Management
List all EC2 instances in your default region:
aws ec2 describe-instances
This returns detailed JSON output for all instances. For a cleaner table view showing only running instances:
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --output table
Stop an EC2 instance:
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
Replace i-1234567890abcdef0 with your actual instance ID.
IAM User and Policy Management
List all IAM users in your account:
aws iam list-users
Create a new IAM user:
aws iam create-user --user-name new-user
Attach a policy to a user:
aws iam attach-user-policy --user-name new-user --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
CloudFormation Stack Operations
Deploy a CloudFormation stack from a template file:
aws cloudformation create-stack --stack-name my-stack --template-body file://template.yaml
Check stack status:
aws cloudformation describe-stacks --stack-name my-stack
Delete a stack:
aws cloudformation delete-stack --stack-name my-stack
For a complete command reference, visit the AWS CLI Command Reference. The AWS CLI GitHub repository contains source code, documentation, and the release changelog.
Update AWS CLI
Update procedures differ by installation method. Use the same approach you used for installation.
Update Official Installer
Download and run the installer with the --update flag:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
unzip awscliv2.zip
sudo ./aws/install --update
The installer replaces the existing version and preserves your configuration files in ~/.aws/. You’ll see:
You can now run: /usr/local/bin/aws --version
Clean up the downloaded files:
rm -rf awscliv2.zip aws/
Verify the new version:
aws --version
Update Snap Package
Snap packages update automatically in the background. Check for updates manually:
sudo snap refresh aws-cli
Update pip Installation
If you installed in a virtual environment, update using the venv pip:
~/.aws-venv/bin/pip install --upgrade awscli
For system-wide installations, update commands differ by Ubuntu version.
Ubuntu 24.04 LTS and 26.04 LTS:
python3 -m pip install --upgrade --break-system-packages awscli
Ubuntu 22.04 LTS:
python3 -m pip install --upgrade awscli
Update awscliv2 Wrapper
If you installed in a virtual environment, update using the venv pip:
~/.awsv2-venv/bin/pip install --upgrade awscliv2
For system-wide installations, update commands differ by Ubuntu version.
Ubuntu 24.04/26.04:
python3 -m pip install --upgrade --break-system-packages awscliv2
Ubuntu 22.04:
python3 -m pip install --upgrade awscliv2
If using Docker execution, update the AWS CLI image:
docker pull amazon/aws-cli
If you installed binaries with awsv2 --install, run the install command again to update:
If you installed the wrapper in a virtual environment and did not add it to your PATH, run
~/.awsv2-venv/bin/awsv2 --installinstead.
awsv2 --install
Troubleshooting
Command Not Found After Installation
If aws returns “command not found” after installation, the binary location is not in your PATH.
Official installer: Verify the symlink exists:
ls -l /usr/local/bin/aws
lrwxrwxrwx 1 root root 37 Jan 11 12:00 /usr/local/bin/aws -> /usr/local/aws-cli/v2/current/bin/aws
Missing symlink? Recreate it manually:
sudo ln -s /usr/local/aws-cli/v2/current/bin/aws /usr/local/bin/aws
sudo ln -s /usr/local/aws-cli/v2/current/bin/aws_completer /usr/local/bin/aws_completer
pip virtual environment: Run the binary directly or add the venv bin directory to your PATH:
~/.aws-venv/bin/aws --version
pip system-wide: The binary should be in /usr/local/bin. Confirm with:
command -v aws
/usr/local/bin/aws
awscliv2: Docker Not Found
If you run awsv2 without Docker or local binaries, you will see an error like this:
2.3.1 AWS CLI v2 command: docker run -i --rm -v /root/.aws:/root/.aws -v /:/aws amazon/aws-cli 10:46:54 - awscliv2 - ERROR - Executable not found: docker
Paths will differ based on your home directory. Install Docker (Method 4) or run awsv2 --install to use local binaries.
Unable to Locate Package (Missing ubuntu.sources)
If apt reports “Unable to locate package” for docker.io, python3-pip, or other dependencies, your ubuntu.sources file may be missing.
Check your sources directory:
ls -la /etc/apt/sources.list.d/
If you see ubuntu.sources.curtin.orig, restore it:
sudo cp /etc/apt/sources.list.d/ubuntu.sources.curtin.orig /etc/apt/sources.list.d/ubuntu.sources
sudo apt update
If no backup exists, create a minimal sources file. Find your codename with lsb_release -cs and replace <codename> in the file below:
cat <<EOF | sudo tee /etc/apt/sources.list.d/ubuntu.sources
Types: deb
URIs: http://archive.ubuntu.com/ubuntu
Suites: <codename> <codename>-updates
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: http://security.ubuntu.com/ubuntu
Suites: <codename>-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
sudo apt update
Authentication Errors
If AWS CLI commands fail with authentication errors, verify your credentials are configured:
aws configure list
Credentials showing <not set>? Run aws configure to set them.
Check that your credentials files exist and are readable:
ls -la ~/.aws/
total 8 drwxr-xr-x 2 username username 4096 Jan 11 12:00 . drwxr-x--- 25 username username 4096 Jan 11 12:00 .. -rw------- 1 username username 29 Jan 11 12:00 config -rw------- 1 username username 116 Jan 11 12:00 credentials
Credentials require restrictive permissions (rw------- or 600) to protect your access keys. Fix incorrect permissions:
chmod 600 ~/.aws/credentials ~/.aws/config
Test authentication by querying your account identity:
aws sts get-caller-identity
{
"UserId": "AIDACKCEVSQ6C2EXAMPLE",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/username"
}
Values will differ on your account. This output confirms authentication is working correctly; persistent failures indicate invalid credentials, expired keys, or insufficient IAM permissions.
SSL Certificate Verification Failed
SSL certificate errors typically indicate missing CA certificates or incorrect system time:
sudo apt install ca-certificates -y
sudo update-ca-certificates
You’ll see:
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d...
If the issue persists, verify your system clock is accurate (certificate validation requires correct time):
timedatectl status
Incorrect time? Enable automatic synchronization:
sudo timedatectl set-ntp true
Remove AWS CLI
Remove AWS CLI using the same method you used for installation. Configuration files can be removed separately if needed.
Remove Official Installer
Remove the installation directory and symlinks:
This removes the AWS CLI install directory under
/usr/local. Double-check the path before runningrm -rf.
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
Verify removal:
aws --version
bash: aws: command not found
Remove Snap Package
Remove AWS CLI installed via Snap:
sudo snap remove aws-cli
Snap automatically removes all files associated with the package.
Remove pip Installation
If you installed in a virtual environment, simply remove the directory:
This deletes the virtual environment directory. Verify the path before running
rm -rf.
rm -rf ~/.aws-venv
If you added the PATH line for the virtual environment, remove export PATH="$HOME/.aws-venv/bin:$PATH" from ~/.bashrc and reload your shell:
source ~/.bashrc
For system-wide installations, uninstall via pip:
python3 -m pip uninstall awscli -y
Remove awscliv2 Wrapper
If you installed in a virtual environment, remove the directory:
This deletes the virtual environment directory. Verify the path before running
rm -rf.
rm -rf ~/.awsv2-venv
If you added the PATH line for the wrapper, remove export PATH="$HOME/.awsv2-venv/bin:$PATH" from ~/.bashrc and reload your shell:
source ~/.bashrc
For system-wide installations, uninstall via pip:
python3 -m pip uninstall awscliv2 -y
If you installed AWS CLI v2 binaries using awsv2 --install, remove the local binaries directory:
This removes
~/.awscliv2and all wrapper-managed binaries. Verify the path before runningrm -rf.
rm -rf ~/.awscliv2
If you used Docker execution, the amazon/aws-cli image remains. Remove it if no longer needed:
docker rmi amazon/aws-cli
Remove Configuration Files (Optional)
AWS CLI stores configuration and credentials in ~/.aws/. Remove these files only if you no longer need saved profiles or credentials.
Back up your configuration first if you might need profiles or credentials later:
cp -r ~/.aws ~/.aws-backup
This permanently deletes all AWS CLI configuration files including credentials, profiles, and CLI history.
rm -rf ~/.aws
Conclusion
AWS CLI is now installed and configured on Ubuntu, so you can authenticate, verify your setup, and automate tasks like S3 transfers and EC2 management. Use the official installer for v2 on production systems, Snap for automatic updates, pip when you need v1 compatibility, or awscliv2 when you want a Python-managed v2 wrapper. Keep credentials in ~/.aws/ and review IAM permissions as you automate.