To resolve the 'zsh: command not found: aws' error when trying to run AWS CLI commands -
-
First, check if AWS CLI is installed: First, check if AWS CLI is already installed by typing:
aws --version
-
If you still see the 'command not found' error, it means AWS CLI is either not installed or not set up properly.
-
Install AWS CLI: If it's not installed, you can install it with these commands: For Mac:
curl "https://awscli.amazonaws.com/AWSCLIV2.pg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
For Linux:
sudo apt install awscli
-
You can also follow the official AWS installation guide for your operating system.
-
Check if AWS CLI is in your system path: Even if AWS CLI is installed, it may not be added to your $PATH. To check, run:
echo $PATH
-
This will show the directories where your system looks for installed programs. If AWS CLI’s location isn’t listed, you'll need to add it manually.
-
Add AWS CLI to your path:To add AWS CLI to your $PATH, you need to edit your .zshrc file by running:
nano ~/.zshrc
-
Add the following line, replacing /path/to/aws-cli with the actual path where AWS CLI is installed:
export PATH=$PATH:/path/to/aws-cli
-
After saving, run:
source ~/.zshrc
-
This will reload your configuration and add AWS CLI to your path.
-
Verify the installation: Once you’ve completed the above steps, verify everything is working correctly by typing:
aws --version
-
This should now show the AWS CLI version, confirming it’s installed properly.
-
Restart your terminal: If you still encounter issues, try restarting your terminal to ensure all changes take effect.
If you need more help or want to learn AWS in detail, check out the this blog and courses for the best resources and certifications on AWS!