#!/bin/bash
# Update package list and install python3-pip
sudo apt update
sudo apt install -y python3-pip
# Install AWS CLI
pip3 install awscli --upgrade-strategy only-if-needed --break-system-packages
# Add the PATH update to .bashrc
echo "export PATH=/usr/local/bin:\$PATH" >> ~/.bashrc
# Source the updated .bashrc
source ~/.bashrc
# Print AWS CLI version
aws --version
echo "AWS CLI setup complete. Please restart your terminal or run 'source ~/.bashrc' to apply the PATH changes."
This script does the following:
- Updates the package list and installs python3-pip
- Installs the AWS CLI using pip3 with the specified options
- Adds the PATH export line to the end of .bashrc
- Sources the updated .bashrc to apply the changes in the current session
- Prints the AWS CLI version
- Outputs a message to remind the user to restart their terminal or source .bashrc again
To use this script:
- Save it to a file, for example,
aws_cli_setup.sh
- Make it executable with
chmod +x aws_cli_setup.sh
- Run it with
./aws_cli_setup.sh
Note that this script will append the PATH export to .bashrc every time it's run. If you plan to run it multiple times, you might want to add a check to see if the line already exists in .bashrc before adding it.