Install and Use AWS CLI on Linux – Ubuntu / Debian / CentOS

Posted on 76 views

In this guide I’ll show you two different ways of installing AWS CLI tool on Linux – These will be Ubuntu/Debian, CentOS and Arch Linux line of distributions. The AWS CLI is an open source tool built on top of the AWS SDK for Python (Boto) that provides commands for interacting with AWS services.

With AWS CLI you can easily develop shell scripts to manage your resources on AWS cloud. If you’re more of a developer, you can create programs using AWS SDK.

Install and Use AWS CLI on Linux

AWS CLI has the following system requirements:

  • Python 2 version 2.6.5+ or Python 3 version 3.3+
  • Windows, Linux, macOS, or Unix Operating system

Install  AWS CLI on Ubuntu / Debian

You can install AWS CLI using python pip or by using the Bundled Installer for Linux. Install the python-pip package on your Ubuntu or Debian system:

sudo apt update
sudo apt -y install python3-pip

Upgrade pip to the latest release:

sudo pip3 install --upgrade pip

Once the package is installed, install awscli  package with pip:

sudo pip3 install awscli

To upgrade pip to the latest version, run:

sudo pip3 install awscli --upgrade

Install AWS CLI on CentOS / Fedora / RHEL using pip:

CentOS 8:

sudo dnf install -y python3 python3-pip
sudo pip3 install awscli

CentOS 7:

First download and install python-pip package:

sudo yum -y install python-pip

Upgrade pip to the latest release:

sudo pip install --upgrade pip

Then run the install of awscli from pip:

sudo pip install awscli

To upgrade pip to the latest version, run:

sudo pip install awscli --upgrade

Install AWS CLI on any Linux using Bundled Installer

The Bundled Installer method works on any Linux distribution, the only requirement is Python 2 version 2.6.5+ or Python 3 version 3.3+.

You can check your Python version using

$ python --version

Step 1: Download the AWS CLI Bundled Installer.

This can be done directly from curl

curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"

Step 2: Unzip the package.

Install unzip package on your Linux distribution:

Ubuntu:

sudo apt -y install unzip

CentOS

sudo yum -y install unzip

Arch Linux

sudo pacman -S unzip

Unzip the package using the command

unzip awscli-bundle.zip

Once the package has been unzipped, install it using:

sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Check version installed:

$ /usr/local/bin/aws --version
aws-cli/1.25.53 Python/3.10.4 Linux/5.15.0-40-generic botocore/1.27.53

You can also install the AWS CLI tool without sudo by putting the binary under ~/bin/aws

curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
./awscli-bundle/install -b ~/bin/aws

Using AWS CLI on Linux

Before you can start using aws CLI tool to interact with AWS services, you need to configure it by running the aws configurecommand.

$ aws configure

This will ask you to provide

  • Your AWS Access Key ID
  • AWS Secret Access Key
  • Default region name
  • Default output format

Sample output is shown below:

AWS Access Key ID [****************M5YB]:
AWS Secret Access Key [****************I5C1]:
Default region name [eu-central-1]:
Default output format [json]:

Once configured, you can start interacting with AWS using aws command

$ aws s3 ls
2022-08-10 04:40:29 Server-Backups
2022-08-10 06:52:45 ERP-Uploads

I recommend you read AWS CLI reference guide to learn how to use AWS CLI with various services.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.