AWS
CLI
PATH
Settings
Command Line

AWS CLI PATH settings: install location and adding aws to PATH

Codemia Knowledge Hub ·

To run aws from any directory, the folder that holds the AWS CLI executable must be on your PATH. On macOS and Linux that is usually /usr/local/bin (or /usr/bin), added in ~/.bash_profile or ~/.zshrc. On Windows, add the install folder (C:\Program Files\Amazon\AWSCLIV2 for the version 2 MSI) to the Path environment variable. Then confirm with aws --version.

The PATH environment variable lists the directories the shell searches for executables when you type a command. This works the same way on Linux, macOS and Windows.

Installing the AWS CLI

Make sure the CLI is installed before changing PATH.

macOS and Linux

  1. Package manager:
    • Homebrew (macOS): brew install awscli
    • APT (Debian/Ubuntu): sudo apt-get install awscli
  2. Bundled installer:
    • Download the installer:
bash
     curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
  • Install it:
bash
     sudo installer -pkg AWSCLIV2.pkg -target /

Windows

Adding the AWS CLI to PATH

macOS and Linux

  1. Find the install location:
    • The AWS CLI is typically installed at /usr/local/bin/aws or /usr/bin/aws.
  2. Edit your shell profile:
    • Open it in the terminal:
bash
     nano ~/.bash_profile  # for bash users
     nano ~/.zshrc         # for zsh users 
  • Add this line:
bash
     export PATH="/usr/local/bin:$PATH"
  • Save and exit (CTRL + X, Y, Enter in nano).
  1. Load the changes:
    • Run:
bash
     source ~/.bash_profile  # or ~/.zshrc

Windows

  1. Find the install path:
    • The version 2 MSI installs to C:\Program Files\Amazon\AWSCLIV2 by default. Version 1 used C:\Program Files\Amazon\AWSCLI\bin.
  2. Set Path:
    • Open the Control Panel and go to System > Advanced system settings > Environment Variables.
    • Under System Variables, select Path and click Edit.
    • Add that folder, for example C:\Program Files\Amazon\AWSCLIV2.
  3. Verify:
    • Open a new Command Prompt window and type:
cmd
     aws --version

Verifying the setup

On any platform, check the version:

bash
aws --version

If it prints the AWS CLI version, the CLI is installed and reachable from any directory.

Steps by platform

StepmacOS/LinuxWindows
Install AWS CLIHomebrew, APT, or Bundled InstallerMSI Installer
Default Install Location/usr/local/bin/awsC:\Program Files\Amazon\AWSCLIV2
Edit $PATHAdd export PATH="/usr/local/bin:$PATH" to ~/.bash_profile or ~/.zshrcAdd directory to Path variable in Environment Variables
Verify InstallationRun aws --versionRun aws --version

Other shells and multiple versions

  • Other shells: fish, tcsh and similar shells set PATH differently. See their documentation.
  • Multiple AWS CLI versions: If several versions of the AWS CLI or related tools are installed, use directory-specific shell initialization files or version managers such as nvm or pyenv to avoid conflicts. After system updates or configuration changes, check that aws still resolves to the version you expect.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

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

View the course
System Design practice on Codemia

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

Practice system design