| by Arround The Web | No comments

Install AWS Command Line Interface (CLI) on Ubuntu 22.04 LTS

AWS CLI or Amazon Web Service Command Line Interface is a command-line tool for managing and administering your Amazon Web Services. AWS CLI provides direct access to the public API (Application Programming Interface) of Amazon Web Services. Since it’s a command-line tool, you can also use it to create scripts for automating your Amazon Web Services.

In this article, I will show you how to install the AWS CLI program on Ubuntu 22.04 LTS using the APT package manager. I will also show you how to install the latest version of the AWS CLI program on Ubuntu 22.04 LTS as a Python module using Python PIP. So, let’s get started.

Table of Contents

  1. Installing AWS CLI using APT Package Manager
  2. Installing AWS CLI using Python PIP
  3. Basics of AWS CLI
  4. Login to AWS Account using AWS CLI
  5. Getting Help with AWS CLI
  6. Conclusion

Installing AWS CLI Using APT Package Manager

AWS CLI is available in the official package repository of Ubuntu 22.04 LTS. So, it is very easy to install.

First, update the APT package repository cache with the following command:

$ sudo apt-get update

The APT package repository cache should be updated.

To install AWS CLI on Ubuntu 22.04 LTS from the official package repository, run the following command:

$ sudo apt-get install awscli

Press Y and then press <Enter> to confirm the installation.

The required packages are being downloaded from the internet. It will take a few seconds to complete.

Once the packages are downloaded, the APT package manager will install them. It will take a few seconds to complete.

AWS CLI should be installed at this point.

To check whether AWS CLI is working correctly with the following command:

$ aws --version

As you can see, AWS CLI is working correctly.

Installing AWS CLI Using Python PIP

AWS CLI is also available as a Python module. The advantage of installing AWS CLI as a Python module is that you always get an up-to-date version of the AWS CLI program. If AWS CLI is installed as a Python module, it will be very easy to update AWS CLI once a new version of AWS CLI is available. You also don’t need superuser privileges to install AWS CLI as a Python module. AWS CLI can also be installed in a Python virtual environment.

AWS CLI is available for Python 2 and Python 3. You must have Python PIP installed on your computer for installing AWS CLI on Ubuntu 22.04 LTS as a Python module. Python PIP is not installed by default on Ubuntu 22.04 LTS. But you can install it easily from the official package repository of Ubuntu.

To install Python PIP on Ubuntu 22.04 LTS, run the following command:

For Python 2:

$ sudo apt install python-pip

For Python 3:

$ sudo apt install python3-pip

Press Y and then press <Enter> to confirm the installation.

Python PIP should be installed.

To install AWS CLI on Ubuntu 22.04 LTS as a Python module using Python PIP, run the following command:

Python 2 PIP:

$ pip install awscli --upgrade --user

Python 3 PIP:

$ pip3 install awscli --upgrade --user

AWS CLI is being installed as a Python module. It will take a few seconds to complete.

The latest version of AWS CLI should be installed as a Python module.

Once AWS CLI is installed as a Python module, you can run AWS CLI as follows:

Python 2 Command:

$ python -m awscli --version

Python 3 Command:

$ python3 -m awscli --version

As you can see, AWS CLI is working correctly.

Basics of AWS CLI

I wanted to show you how to work with AWS CLI practically. But I don’t have a credit card, so I can’t verify my AWS account. But don’t worry; I will give you enough information so that you can get started with AWS CLI on Ubuntu 22.04 LTS.

In this section, I will be using the Ubuntu 22.04 LTS packaged version of the AWS CLI program, not the Python module version. So, make sure to adjust the command if you’re using the Python module version of the AWS CLI program.

Login to AWS Account Using AWS CLI

First, you have to use your AWS account credentials to configure the AWS CLI client. To do that, run the following command:

Ubuntu Packaged AWS CLI:

$ aws configure

AWS CLI Python Module:

$ python -m awscli configure

Type in your AWS Access Key ID and press <Enter>.

NOTE: An Access Key ID can be created from the AWS Management Console.

Type in your AWS Secret Access Key ID and press <Enter>.

NOTE: A Secret Access Key ID can be created from the AWS Management Console.

Type in your default region name. It’s something like us-west-2. Once you’re done, press <Enter>.

Type in your default output format. If the output format does not matter much to you, just press <Enter> to choose the default output format.

If you prefer to use the JSON (JavaScript Object Notation) output format, type in json and press <Enter>.

Once you’ve configured the AWS CLI program with your AWS account credentials, you should be able to manage your Amazon Web Services using AWS CLI.

The configuration files of the AWS CLI program are stored in the ~/.aws/config and ~/.aws/credentials files, as you can see in the screenshot below.

If you want to use different AWS account credentials, you have to delete the ~/.aws/config and ~/.aws/credentials files with the following command and run the aws configure command again.

$ rm -v ~/.aws/config ~/.aws/credentials

Getting Help With AWS CLI

To figure out how to use the AWS CLI program, you can read the AWS CLI man pages. AWS also has a great guide and online documentation on AWS CLI that you can read to learn more about AWS CLI.

To get help on the AWS CLI program from the terminal, you can run the following command:

$ aws help

Or,

$ python -m awscli help

Or,

$ python3 -m awscli help

AWS CLI man page is opened on the terminal. You can learn a lot of stuff from the AWS CLI man page.

AWS has different services such as EC2, S3, etc. To get help on configuring specific AWS services using AWS CLI, you can read the respective man pages as follows:

$ aws <service-name> help

NOTE: Here, <service-name> is the AWS service name that you want to learn how to configure using the AWS CLI program.

For example, to learn more about configuring the AWS S3 object storage service using AWS CLI, you can run the following command:

$ aws s3 help

For more information, you can check the official online documentation of the AWS CLI program.

You can also download the official AWS CLI PDF manual.

Conclusion

This article shows you how to install the AWS CLI program on Ubuntu 22.04 LTS using the APT package manager. I have also shown you how to install the latest version of the AWS CLI program on Ubuntu 22.04 LTS as a Python module. I have shown you how to log in to your AWS account using the AWS CLI program as well. Finally, I have shown you how to get help on the AWS CLI program so that you can learn more about configuring different AWS services with it.

Share Button

Source: linuxhint.com

Leave a Reply