How to install AWS CLI on Ubuntu? [SOLVED]


Written By - Omer Cakmak
Advertisement

What is AWS CLI?

AWS CLI (AWS Command Line Interface) is a unified tool you can use to manage your AWS services. With the AWS CLI, you can control multiple AWS services from the command line and automate them via scripts.

In this article, we will examine how to install this tool on Ubuntu.

 

Method-1: Install AWS CLI from Repository

With the steps in this method, you will be able to use the aws cli package in the Ubuntu repository by installing it. First update the package list:

foc@ubuntu22:~$ sudo apt update -y

Package version in the repository:

foc@ubuntu22:~$ sudo apt search awscli
Sorting... Done
Full Text Search... Done
awscli/jammy 1.22.34-1 all
Universal Command Line Environment for AWS

Install package now:

foc@ubuntu22:~$ sudo apt install awscli -y

Installation complete, version:

foc@ubuntu22:~$ aws --version
aws-cli/1.22.34 Python/3.10.4 Linux/5.15.0-46-generic botocore/1.23.34

It is required by configuring the AWS CLI client with the configure parameter, you must use your AWS account credentials:

foc@ubuntu22:/tmp$ aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

 

Method-2: Install AWS CLI from zip File

Note: The AWS CLI uses glibc, groff, and "less". These are included by default in Ubuntu as in most Linux distributions. If these packages are not available on your system, install these packages in the installation of the requirement packages below.

Advertisement

In this method, the following package must be installed first:

foc@ubuntu22:~$ sudo apt install unzip -y

Then the zip file is downloaded with curl:

foc@ubuntu22:~$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --  5 46.0M    5 2799k

Compressed file opens:

foc@ubuntu22:~$ unzip awscliv2.zip

Finally, the installation starts:

foc@ubuntu22:~$ sudo ./aws/install
You can now run: /usr/local/bin/aws --version

Installation complete, version:

foc@ubuntu22:/tmp$ aws --version
aws-cli/2.9.3 Python/3.9.11 Linux/5.15.0-46-generic exe/x86_64.ubuntu.22 prompt/off

You can log in using your AWS account credentials:

foc@ubuntu22:/tmp$ aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

In this way, you should use the following command for upda while using aws cli:

foc@ubuntu22:$ sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

 

Method-3: Install AWS CLI using PIP

The last method we would recommend for using the AWS CLI application on Ubuntu is to use pip. First update the package list:

Advertisement
foc@ubuntu22:~$ sudo apt update -y

Then the pip package is installed. If you are using python3, install pip, if you are using python2, install the pip package.

For Python3:

foc@ubuntu22:~$ sudo apt install python3-pip -y

For Python2:

foc@ubuntu22:~$ sudo apt install python-pip -y

Then install awscli with pip. For Python2:

foc@ubuntu22:~$ pip install awscli

For Python3:

foc@ubuntu22:~$ pip3 install awscli

Package version after installation:

Advertisement
foc@ubuntu22:~$ python3 -m awscli --version
aws-cli/1.27.22 Python/3.10.6 Linux/5.15.0-46-generic botocore/1.29.22

In this method, you can log in using your AWS account credentials as follows:

foc@ubuntu22:~$ python3 -m awscli configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

 

Summary

You can use the following command to get manual information about AWS CLI:

foc@ubuntu22:~$ aws help

NAME        aws 

DESCRIPTION
       The  AWS  Command  Line  Interface is a unified tool to manage your AWS
       services.

SYNOPSIS
          aws [options] <command> <subcommand> [parameters]

       Use aws command help for information on a  specific  command.  Use  aws
       help  topics  to view a list of available help topics. The synopsis for
       each command shows its parameters and their usage. Optional  parameters
       are shown in square brackets.
...

You can install and use AWS CLI with 3 methods above. If there is no special reason, install it from the Ubuntu repository and use it. The package will be stable and easy to update.

References

docs.aws.amazon.com - Installing or updating the latest version of the AWS CLI

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment