AWS CLI on Ubuntu
Installation

Install AWS CLI on Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

If you are into servers or DevOps, AWS is one of the most crucial things to have in your tech stack.

To manage, configure and control multiple AWS services, you can use the AWS CLI tool from Amazon.

It is available in Ubuntu's Universe repository, although it may not be the latest version.

You can install it using this command:

sudo apt install awscli

Once done, you can check the installed version using:

aws --version
check installed version of aws cli in ubuntu

And as you can see, I got AWS CLI version 1.22.34.

But if you want the latest version possible, it needs to be installed manually and in this tutorial, I will show you how to do it.

How to install the latest version of AWS CLI in Ubuntu

To install the latest version of AWS CLI in Ubuntu, first, you'd have to install prerequisites using the following:

sudo apt install curl unzip

First, download the zip file using the curl command as shown:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
install the latest version of aws cli in Ubuntu

Now, use the unzip command to extract files:

unzip awscliv2.zip

And finally, use the following command to install the AWS CLI:

sudo ./aws/install

Once done, you can check the installed version using the following:

aws --version
check installed version of AWS CLI in Ubuntu

As you can see, I got AWS CLI version 2.11.24 which is far ahead of what I got using the apt.

How to configure AWS CLI in Ubuntu

First, let's have a look at how you can access your Access key and secret keys.

First, log in to your console using the browser, and click on your profile. Here, it will show the option Security credentials:

How to generate secret keys for AWS CLI

Now, find the option for Aceess keys here it will show keys if you have generated them previously.

And if you haven't, then, you can generate keys by clicking on Create access key:

generate new access keys for AWS CLI in Ubuntu

It will create the keys for you.

Now, you have keys, so let's start the configuration.

To start the configuration, all you have to do is append the configure flag to the aws command:

aws configure

And enter the details:

configure AWS CLI in Ubuntu

That's it! The AWS is configured.

Once you are done with the configuration, it will create two directories inside $HOME/.aws and you can check out its contents using the ls command:

ls $HOME/.aws
directories created after configuring AWS CLI

But what are those files? Let me explain:

  • config: Contains all the information related to the configuration you made such as default region and type of default output.
  • credentials: Contains access key and secret key as plain text.

Now, let's put the configuration to the test.

You can use the following command and it will print information about the instances you've created:

aws ec2 describe-instances
Test AWS CLI

Working as expected! Enjoy controlling your AWS services from Ubuntu.



Sagar Sharma

Sagar Sharma

A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.