aws-cli
uninstall guide
command line tools
cloud computing
software removal

How to uninstall aws-cli

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Uninstalling AWS CLI cleanly requires knowing which version and install method you used. AWS CLI v1 is usually installed with pip, while AWS CLI v2 is commonly installed by package manager or bundled installer. If you remove only one path, old binaries or credentials may remain and cause confusing behavior.

Identify Version and Binary Location

Start by checking active version and executable path.

bash
aws --version
which aws

On Windows PowerShell:

powershell
aws --version
Get-Command aws

Typical version output:

  • aws-cli/1.x means AWS CLI v1.
  • aws-cli/2.x means AWS CLI v2.

Record path output before uninstall so you can verify removal later.

Uninstall AWS CLI v1 Installed with pip

If version is v1 and installed through Python tooling, remove with the same pip context used at install time.

bash
pip uninstall awscli

If you use pip3:

bash
pip3 uninstall awscli

If installed in a virtual environment, activate that environment first, then run uninstall. For system wide installs, you may need elevated privileges depending on your OS policy.

Uninstall AWS CLI v2 on macOS and Linux

For Homebrew installs on macOS:

bash
brew uninstall awscli

For bundled installer layout, remove the symlink and install directory:

bash
sudo rm -f /usr/local/bin/aws
sudo rm -f /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli

Some systems use alternate directories. If which aws points elsewhere, remove that location instead.

On Linux, if you installed with custom flags such as --bin-dir or --install-dir, use your custom paths:

bash
sudo rm -f /custom/bin/aws
sudo rm -rf /custom/aws-cli

Uninstall AWS CLI v2 on Windows

For MSI or installer based setup:

  1. Open Settings and navigate to Apps.
  2. Find AWS Command Line Interface v2.
  3. Select uninstall.

PowerShell option:

powershell
msiexec /x AWSCLIV2.msi

If uninstall entry remains but command is missing, restart shell and confirm PATH cleanup.

Remove AWS Configuration and Credentials if Needed

Uninstalling binaries does not remove AWS profiles or keys stored in user configuration directories. Delete only if you no longer need these credentials.

macOS and Linux:

bash
rm -rf ~/.aws

Windows PowerShell:

powershell
Remove-Item -Recurse -Force "$env:USERPROFILE\.aws"

If multiple users share a machine, inspect each profile location separately.

Verify Complete Removal

Open a new terminal session and run:

bash
aws --version

Expected result is command not found or equivalent error. Then check lingering executables:

bash
which aws

On Windows:

powershell
where aws

If a path still appears, remove that binary and review shell PATH entries.

Reinstall Cleanly if Required

If your goal is version migration, reinstall immediately after cleanup using one consistent method only. Mixing package manager and bundled installer on the same machine often leads to path conflicts.

Simple reinstall verification:

bash
aws --version
aws configure list

This confirms both executable resolution and profile loading.

Automate Verification in CI Images

If you maintain base images, add a short verification step after uninstall so stale binaries do not survive layered image caches.

bash
1if command -v aws >/dev/null 2>&1; then
2  echo \"aws still present\"
3  exit 1
4fi

This check catches partial removal early and keeps build environments consistent.

Common Pitfalls

  • Running v1 uninstall commands against a v2 bundled install.
  • Forgetting custom install directories used during initial setup.
  • Leaving old binary symlinks in PATH after uninstall.
  • Assuming uninstall removed credential files automatically.
  • Using multiple install methods that conflict on command resolution.

Summary

  • Detect AWS CLI version and path before removing anything.
  • Use uninstall steps that match install method and operating system.
  • Remove leftover symlinks and directories for complete cleanup.
  • Delete ~/.aws only when you intend to remove stored credentials.
  • Validate removal in a fresh shell so cached paths do not mislead you.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.