How to Update AWS CLI via the Command Line

This guide is split into two sections: how to install AWS CLI via the command line and how to update AWS CLI via the command line. It explains how to do this for Linux, Windows, and macOS.

Part 1: Install CLI

Part 2: Update CLI


PART1: Install AWS CLI via Command Line

Install the AWS CLI via the Command Line on Linux (Ubuntu)

Step 1: Update Package Lists

Bash
sudo apt update -y

Step 2: Install pip and unzip

Bash
sudo apt install python3-pip unzip -y

Step 3: Download and Install the AWS CLI

Bash
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install 

Step 4: Verify Installation

Bash
aws --version

Install the AWS CLI via the Command Line on Windows using PowerShell

Step 1: Download the Installer

PowerShell
Invoke-WebRequest -Uri https://awscli.amazonaws.com/AWSCLIV2.msi -OutFile .\AWSCLIV2.msi 

Step 2: Run the Installer

Double-click the downloaded “AWSCLIV2.msi” file and follow the on-screen instructions.

Step 3: Verify Installation

Open a new PowerShell window and run:

PowerShell
aws --version 

Install the AWS CLI via the Command Line on MacOS (Terminal):

Step 1: Install Homebrew (if not already installed)

Bash
bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install the AWS CLI

Bash
brew install awscli

Step 3: Verify Installation

Bash
aws --version


PART 2: Update AWS CLI via Command Line

The update process is generally the same across operating systems:

Update AWS CLI via the Command Line on Linux (Ubuntu)

Step 1: Remove Existing Version

Bash
pip3 install --upgrade awscli 

Note: Use pip instead of pip3 if your Python environment defaults to Python 2)

Step 2: Verify Update

Bash
aws --version 

Update AWS CLI via the Command Line on Windows (PowerShell)

Step 1: Update with MSI Installer

If you originally installed the AWS CLI using the MSI installer, the recommended way to update is by downloading and running the latest MSI installer again from the official AWS website. This will overwrite the older version with the updated one.

PowerShell
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

Step 2: Update with pip (Alternative)

You can also try updating using pip (if you have it installed):

PowerShell
pip install --upgrade awscli 

Step 3: Verify Update

PowerShell
aws --version 

Update AWS CLI via the Command Line on MacOS (Terminal)

Step 1: Update with brew

Bash
brew upgrade awscli

Step 2: Verify Update

Bash
aws --version 

Important Notes:

  • Administrative Privileges: You’ll likely need administrative rights (e.g., sudo on Linux/MacOS or running PowerShell as Administrator) to install or update system-wide.
  • Alternative Update Methods:
    • Windows: If you installed using the MSI installer, you might need to download and re-run the latest installer to get updates.
    • Linux: Some package managers (like apt) might offer update mechanisms (sudo apt install --only-upgrade awscli).
  • Shell Restart: After updating, it’s a good practice to restart your terminal or command prompt.
Elsewhere On TurboGeek:  Popular Linux Distributions

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »