(Last Updated On: November 30, 2018)

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 – Ubuntu / Debian / CentOS Requirements

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 AWS CLI on Ubuntu / Debian using pip

Install the python-pip package on your Ubuntu or Debian system

sudo apt-get update
sudo apt-get install python-pip

Upgrade pip to the latest release

sudo pip install --upgrade pip

Once the package is installed, install awscli  package with pip

sudo pip install awscli

To upgrade pip to the latest version, run:

sudo pip install awscli --upgrade

Install AWS CLI on CentOS using pip

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-get install unzip

CentOS

sudo yum 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.16.6 Python/2.7.15rc1 Linux/4.15.0-30-generic botocore/1.11.6U

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
2018-08-30 04:40:29 Server-Backups
2018-08-30 06:52:45 ERP-Uploads

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

Other AWS articles available in our blog are:

How to extend EBS boot disk on AWS without an instance reboot

Create AWS S3 Upload and List Objects Policy without Delete Action

How to Configure Cpanel Backups to S3 Object Store

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

How to Reset RDS Master User Password on AWS