How to Install AWS CLI on Linux Step-by-Step

This post describes how to install AWS CLI on linux step-by-step. AWS CLI is a command line interface which allows us to interact with our AWS account. Developer and sysadmin use aws cli to perform day to day activities and automation.

Prerequisites

  • Pre-Installed Linux System
  • Sudo User with admin rights
  • Internet Connectivity

Without any further delay, let’s jump into AWS Cli installations steps.

1) Download Installation File

Open the terminal and run following curl command to download aws cli installation file,

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

Download-AWS-CLI-Curl-Command

Above command will download file as ‘awscliv2.zip’ in current working directory.

Execute below ls command to verify downloaded file,

$ ls -l awscliv2.zip
-rw-rw-r-- 1 linuxtechi linuxtechi 47244662 Oct 20 10:53 awscliv2.zip
$

2) Unzip Downloaded Installation File

Run beneath unzip command to unzip the installer.

$ unzip awscliv2.zip

It will create aws folder in present working directory and unzip all required files into it.

$ ls -ld aws
drwxr-xr-x 3 linuxtechi linuxtechi 4096 Oct 19 17:18 aws
$

3) Install AWS Cli on Linux Using Install Script

To install aws cli, run following install script,

$ sudo ./aws/install

Install AWS Cli on Linux

Script will install all files under /usr/local/aws-cli and will create symbolic link in /usr/local/bin.

4) Verify AWS CLI version

To verify the aws cli version, run

$ aws --version
aws-cli/2.8.4 Python/3.9.11 Linux/5.15.0-48-generic exe/x86_64.ubuntu.22 prompt/off
$

5) Configure AWS CLI

To verify the AWS Cli installation, let’s configure aws cli.

Login to your AWS management console and retrieve AWS access key id and secret access key.

In case it is not created yet then create access key ID and secret access key. Copy these keys somewhere safe.

AWS-Account-Access-Secret-Key

Now head back to Linux terminal, run following aws command,

$ aws configure
AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxx
Default region name [None]: us-west-2
Default output format [None]: json
$

Above credentials will be saved in following file,

$ cat  ~/.aws/credentials

Output of above commands,

AWS-Configure-Command-Output-Linux

Run aws command to list s3 bucket and vpc of your account.

$ aws s3 ls
$ aws ec2 describe-vpcs

Output,

AWS-Command-List-S3-VPC

Output above confirms that aws cli has been configured successfully.

That’s all from this post, feel free to post your queries and feedback in below comments sections.

Also Read: How to Setup EKS Cluster along with NLB on AWS

Leave a Comment

Your email address will not be published. Required fields are marked *