How to uninstall AWS CLI

As an AWS Solutions Architect, I’ve helped many clients remove the AWS CLI from their systems. In this article, I’ll walk you through the various methods to uninstall AWS CLI across different operating systems and installation types. By the end of this tutorial, you’ll have a clear understanding of how to remove AWS CLI from your system entirely.

How to uninstall AWS CLI

Case 1: On Windows

Method 1: Using Control Panel

To uninstall AWS CLI, follow the steps below.

  1. Open the Control Panel –> Click on Programs –> Click on Programs and Features.
  2. Select the AWS Command Line Interface and click the Uninstall button, as highlighted below.
How to uninstall AWS CLI

You can also right-click the AWS Command Line Interface and then select the Uninstall option.

3. Click the Yes button to confirm the uninstallation process on the next pop-up.

Method 2: Using pip

If you installed AWS CLI using pip (Python package manager), use:

pip uninstall awscli -y

Or if you used pip3:

pip3 uninstall awscli -y

Case 2: On Linux

The uninstallation method depends on the approach used during your initial installation. You can easily uninstall the AWS CLI on Linux by removing the two items below using the two commands below

$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws

Method 1: For Snap Installations

If you installed AWS CLI using snap:

sudo snap remove aws-cli

You might also need to remove the AWS folder in the snap directory:

sudo rm -rf /snap/aws-cli

Method 2: For Pip Installations on Linux

For Python-based installations:

sudo pip uninstall awscli -y
# OR
sudo pip3 uninstall awscli -y

Method 3: For Yum-Based Distributions (Amazon Linux, CentOS, RHEL)

If you installed using yum:

sudo yum remove awscli

Case 3: On Ubuntu

If you have decided to uninstall the AWS CLI on Ubuntu, you can do that using the following commands.

Execute the command below to uninstall the AWS CLI on Ubuntu.

sudo apt-get remove  awscli

If you want to uninstall the AWS CLI package and its dependencies, you can use the following command.

sudo apt-get remove --auto-remove awscli

To remove the AWS CLI and all its configurations, you can use the following command.

sudo apt-get purge awscli

Or, for the same purpose, you can also use the command below.

sudo apt-get purge --auto-remove awscli

Case 4: On Mac

macOS users typically install AWS CLI via Homebrew, the bundled installer, or pip. Let’s cover each method.

Method 1: Uninstalling AWS CLI Version 2 (Bundled Installer)

If you installed AWS CLI version 2 using the macOS bundled installer:

  1. Open Terminal
  2. Run the uninstall command:
sudo rm -rf /usr/local/aws-cli
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
  1. Verify the uninstallation by running:
aws --version

If the command is not found, the uninstallation is successful.

Method 2: Using Homebrew

If you installed AWS CLI using Homebrew:

brew uninstall awscli

Method 3: Using Pip

For Python-based installations:

pip uninstall awscli -y
# OR
pip3 uninstall awscli -y

This method is compatible with multiple platforms and is commonly used by developers who need to manage various Python packages.

Verifying Complete Uninstallation

After following the appropriate uninstallation method for your system, it’s essential to verify that AWS CLI has been completely removed:

  1. Open a new terminal or command prompt window
  2. Run the following command:
aws --version

If the AWS CLI has been successfully uninstalled, you should see a “command not found” error or a similar message, as shown in the screenshot below.

how to uninstall aws cli on windows

Removing AWS CLI Configuration Files

Uninstalling the AWS CLI doesn’t automatically remove your configuration files, which include your credentials and settings. These are stored in the .aws directory in your home folder:

  • Windows: C:\Users\USERNAME\.aws
  • macOS and Linux: ~/.aws/

If you want to remove these files as well (recommended if you’re completely moving away from AWS):

Windows:

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

macOS and Linux:

rm -rf ~/.aws

Best Practices

  1. Back up your configuration: Before uninstalling, consider backing up your .aws directory if you plan to reinstall later.
  2. Revoke access keys: If you’re permanently removing AWS CLI for security reasons, consider deactivating or rotating your access keys in the IAM console.
  3. Use the appropriate method: Always use the same method to uninstall as you used to install (package manager for package manager installations, etc.).

Conclusion

Uninstalling AWS CLI is a straightforward process once you know which method to use for your specific installation type and operating system. Whether you’re troubleshooting issues or simply cleaning up your system, proper uninstallation ensures you maintain a clean environment.

In this article, we discussed how to uninstall AWS CLI on Windows, Linux, and macOS. By following this article, you should now have successfully removed AWS CLI from your system. Thanks for reading this article !!!

You may also like the following articles

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!