How to uninstall AWS CLI version 2?

· 1 min read
How to uninstall AWS CLI version 2?

If you already have AWS Command Line Interface (AWS CLI 2) and want to uninstall it from your system, then you will find all the steps to remove it.

Find symbolic link for aws program.  This will give you the --bin-dir

abhijit@awsjunkie:~$ which aws
/usr/local/bin/aws

Find installation directory (--install-dir=/usr/local/aws-cli/) and symbolic links for aws and aws_completer.

abhijit@awsjunkie:~$ ls -l /usr/local/bin/
total 15864
drwxr-xr-x 2 root root     4096 May 12 21:18 __pycache__
lrwxrwxrwx 1 root root       37 Jun 27 14:23 aws -> /usr/local/aws-cli/v2/current/bin/aws
lrwxrwxrwx 1 root root       47 Jun 27 14:23 aws_completer -> /usr/local/aws-cli/v2/current/bin/aws_completer
-rwxr-xr-x 1 root root     1695 May 12 21:18 jp.py
-rwxr-xr-x 1 root root 16236544 Jun 29 22:39 oh-my-posh
lrwxrwxrwx 1 root root       38 Jun 30 19:46 sam -> /usr/local/aws-sam-cli/current/bin/sam

Delete symbolic links for aws and aws_completer.

abhijit@awsjunkie:~$ sudo rm /usr/local/bin/aws
abhijit@awsjunkie:~$ sudo rm /usr/local/bin/aws_completer

Remove installation directory (e.g. /usr/local/aws-cli/).

abhijit@awsjunkie:~$ sudo rm -rf /usr/local/aws-cli

Remove  .aws directory that stores AWS SDK, CLI configuration and credential files .

abhijit@awsjunkie:~$ sudo rm -rf ~/.aws/

Verify

abhijit@awsjunkie:~$ aws --version
Command 'aws' not found, but can be installed with:
sudo apt install awscli

References