Introduction
The error -bash: aws: command not found means your shell cannot locate the aws CLI binary. This happens because the AWS CLI is not installed, or its installation directory is not in your PATH environment variable. The fix is either to install the AWS CLI or to add its install location to your PATH.
Check If AWS CLI Is Installed
1# Check if aws exists anywhere on the system
2which aws
3# If installed: /usr/local/bin/aws
4# If not: no output or "aws not found"
5
6# Try the full path directly
7/usr/local/bin/aws --version
8# aws-cli/2.15.0 Python/3.11.6 Linux/5.15.0
9
10# Check common install locations
11ls /usr/local/bin/aws
12ls /usr/bin/aws
13ls ~/.local/bin/aws
14ls /opt/homebrew/bin/aws
Fix 1: Install AWS CLI v2
macOS
1# Download and install (official method)
2curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
3sudo installer -pkg AWSCLIV2.pkg -target /
4
5# Or use Homebrew
6brew install awscli
7
8# Verify
9aws --version
Linux (x86_64)
1curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
2unzip awscliv2.zip
3sudo ./aws/install
4
5# Default install location: /usr/local/bin/aws
6aws --version
Linux (ARM)
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Windows
1# Download the MSI installer from:
2# https://awscli.amazonaws.com/AWSCLIV2.msi
3# Or use Chocolatey:
4choco install awscli
pip (AWS CLI v1 — legacy)
pip install awscli
# or
pip3 install awscli
Fix 2: Add AWS CLI to PATH
If aws is installed but your shell cannot find it, the install directory is not in your PATH:
1# Find where aws is installed
2find / -name "aws" -type f 2>/dev/null
3# Common results:
4# /usr/local/bin/aws
5# /usr/local/aws-cli/v2/current/bin/aws
6# ~/.local/bin/aws
7
8# Add to PATH in your shell config file
9# For bash:
10echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
11source ~/.bashrc
12
13# For zsh:
14echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
15source ~/.zshrc
16
17# For bash on macOS (older versions):
18echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
19source ~/.bash_profile
Fix 3: pip Install Not in PATH
When installed via pip, the aws binary goes into Python's scripts directory, which may not be in your PATH:
1# Find pip's install location
2python3 -m site --user-base
3# Example: /Users/yourname/.local
4
5# The aws binary is at: /Users/yourname/.local/bin/aws
6# Add it to PATH:
7echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
8source ~/.bashrc
9
10# Or use pip to show the exact location
11pip3 show awscli | grep Location
Fix 4: Symlink the Binary
If aws is installed in a non-standard location, create a symlink:
1# Find the actual binary
2which aws || find / -name "aws" -type f 2>/dev/null
3
4# Create symlink to a directory already in PATH
5sudo ln -s /usr/local/aws-cli/v2/current/bin/aws /usr/local/bin/aws
6sudo ln -s /usr/local/aws-cli/v2/current/bin/aws_completer /usr/local/bin/aws_completer
Fix 5: Docker / Container Environments
In Docker containers, AWS CLI is not pre-installed:
1# Debian/Ubuntu-based image
2FROM ubuntu:22.04
3RUN apt-get update && apt-get install -y curl unzip \
4 && curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
5 && unzip awscliv2.zip \
6 && ./aws/install \
7 && rm -rf awscliv2.zip aws
8
9# Alpine-based image
10FROM alpine:3.18
11RUN apk add --no-cache python3 py3-pip \
12 && pip3 install awscli
Verify Installation
1# Check version
2aws --version
3# aws-cli/2.15.0 Python/3.11.6 Darwin/23.0.0
4
5# Check PATH
6echo $PATH | tr ':' '\n' | grep -E "(local|aws)"
7
8# Configure credentials
9aws configure
10# AWS Access Key ID: ****
11# AWS Secret Access Key: ****
12# Default region name: us-east-1
13# Default output format: json
14
15# Test connectivity
16aws sts get-caller-identity
Common Pitfalls
Wrong shell config file: Editing ~/.bashrc when your terminal uses zsh (default on macOS since Catalina). Check your shell with echo $SHELL and edit the correct file (~/.zshrc for zsh).
Forgetting to source: After editing ~/.bashrc or ~/.zshrc, run source ~/.bashrc or open a new terminal. Changes do not apply to the current session automatically.
sudo vs user install: sudo ./aws/install puts the binary in /usr/local/bin/. Without sudo, it installs to ~/.local/bin/ which may not be in your PATH.
Multiple Python versions: pip install awscli installs for one Python version. If your default python changes, the aws binary may point to the wrong Python. Use pip3 explicitly.
AWS CLI v1 vs v2: pip install awscli installs v1 (legacy). The official installer installs v2. They have different install locations and some command differences.
Summary
The error means the aws binary is not in your shell's PATH
Install AWS CLI v2 using the official installer (not pip) for the latest features
Add the install directory to PATH in your shell config file (~/.bashrc, ~/.zshrc, or ~/.bash_profile)
Use which aws and echo $PATH to diagnose path issues
Run source ~/.bashrc after editing to apply changes to the current session
Use aws --version to verify the installation is working