The AWS CLI is a command line interface built on top of the AWS APIs. It makes it easy to manage and automate the usage of Amazon Web Services directly from your terminal without having to use a browser or third-party applications. In this article, we will learn how to install AWS CLI on Linux operating system. The official documentation for AWS CLI is available at https://docs.aws.amazon.com/cli/. You can also read about its general usage at https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-help.html. Below are some common scenarios where you may need to install AWS CLI on Linux operating system and their solutions:
How to Install AWS CLI on Linux
The AWS CLI version 2 packages are available under the default repositories. You can use the package manager for installing AWS CLI v2 on your Linux systems.
Choose one of the below commands to install:
- Ubuntu and Debian-based Systems
sudo apt install awscli
- Fedora and CentOS 9/8
sudo dnf install awscli
- CentOS 7 and Scientific Linux
sudo yum install awscli
- Other than the package manager, you can directly install using source code. This will install the latest awscli version on any Linux platform.
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Generate Access Credentials
To use AWS CLI with your AWS credentials, you need to set the credentials of your AWS account in the environment variables of your system. The credentials are used to authenticate your request in order to access the AWS APIs using AWS CLI. If you are accessing an Amazon Web Services (AWS) resource from a computer that is not registered with AWS, you need to authenticate as an AWS user.
To generate new credentials follow:
- Head to AWS Security Credentials.
- Expand option Access keys (access key ID and secret access key)
- Click the button Create New Access Key
- Copy the access key ID and secret access key and save to a safe place
Configure AWS CLI
You can authenticate with AWS and set your credentials for the number of AWS services from the command line. AWS credentials are managed using credentials profiles. Credentials profiles store your account name, access key ID, and secret access key. Credentials are selected when you issue the AWS CLI command. You can manage the credentials through the AWS console or from the command line.
To set credentials in the AWS CLI, you can use the following command:
This will prompt for AWS Access Key ID and Secret Access Key created in the above step.
AWS Access Key ID [None]: ABCDEFXXXXXXXXDKKDFJ AWS Secret Access Key [None]: 3SDFskjf8KDfjksdf9sdfjsdkfjkKSDKSJFKD Default region name [None]: us-east-1 Default output format [None]:
That’s it. Your system is configured with the AWS CLI tools.
Working with AWS CLI Commands
AWS CLI tools provide your option to manage multiple services via the command line. To get help about uses type:
Here are a few example commands to work with aws cli:
- List all the instances
aws ec2 describe-instances
- List instances from other zone
aws ec2 describe-instances --region=us-west-1
- List S3 buckets
aws s3 list
The article discussed the installation of AWS CLI on Linux and the ways to install the AWS SDK using pip. AWS CLI is a command line interface built on top of the AWS APIs. It makes it easy to manage and automate the usage of Amazon Web Services directly from your terminal without having to use a browser or third-party applications.