Installing AWS CLI on Linux


Introduction

Amazon Web Services (AWS) is one of most popular cloud computing platforms in world. It provides a wide range of services, such as storage, computing, networking, and databases, to name a few. AWS Command Line Interface (CLI) is a powerful tool that allows you to manage your AWS resources using commands in terminal or shell. In this article, we will discuss how to install AWS CLI on Linux, including various sub-headings and examples.

Step 1: Check Python Installation

Before installing AWS CLI, you need to ensure that Python is installed on your Linux system. Python is a programming language that AWS CLI is built on. To check whether Python is installed on your Linux system or not, open terminal and type following command −

python3 --version

This command will return installed Python version on your system. If you see a Python version, it means that Python is already installed on your system. Otherwise, you need to install Python before proceeding to next step.

Step 2: Install AWS CLI

Once you have confirmed that Python is installed on your system, you can proceed with installation of AWS CLI. You can install AWS CLI on Linux using several methods, such as using pip, package manager, or downloading binary package. In this article, we will discuss two popular methods to install AWS CLI on Linux.

Method 1: Install AWS CLI using pip

Pip is a package manager for Python that allows you to install, upgrade, and remove Python packages. To install AWS CLI using pip, you need to follow these steps −

  • Step 1 − Open terminal and type following command to install pip −

sudo apt-get install python3-pip
  • Step 2 − Once pip is installed, type following command to install AWS CLI −

sudo pip3 install awscli

This command will install AWS CLI on your Linux system. To verify installation, type following command −

aws --version

This command will display installed AWS CLI version on your system.

Method 2: Install AWS CLI using package manager

Most Linux distributions have a package manager that allows you to install software packages. You can use package manager to install AWS CLI on Linux. following steps show you how to install AWS CLI using package manager.

  • Step 1 − Open terminal and type following command to update package manager −

sudo apt-get update
  • Step 2 − Once package manager is updated, type following command to install AWS CLI −

sudo apt-get install awscli

This command will install AWS CLI on your Linux system. To verify installation, type following command −

aws --version

This command will display installed AWS CLI version on your system.

Step 3: Configure AWS CLI

After installing AWS CLI, you need to configure it to access your AWS resources. following steps show you how to configure AWS CLI.

  • Step 1 − Open terminal and type following command to start configuration process −

aws configure

This command will prompt you to enter following details −

  • AWS Access Key ID

  • AWS Secret Access Key

  • Default region name

  • Default output format

  • Step 2 − To obtain your AWS Access Key ID and AWS Secret Access Key, go to AWS Management Console and navigate to IAM service. Create a new user or use an existing user and generate Access Key ID and Secret Access Key.

  • Step 3 − Enter your AWS Access Key ID and AWS Secret Access Key when prompted by configuration wizard.

  • Step 4 − Next, enter default region name. This is region where you want to deploy your resources. You can find a list of available regions on AWS documentation.

  • Step 5 − Finally, enter default output format. default output format is JSON, but you can choose any other format, such as YAML or text.

  • Step 6 − Once you have entered all required information, AWS CLI will create a configuration file in your home directory. This file contains your access keys and other configuration details. You can view and edit this file using a text editor.

Step 4: Using AWS CLI

Once you have configured AWS CLI, you can start using it to manage your AWS resources. AWS CLI provides a wide range of commands to manage your resources, such as EC2 instances, S3 buckets, RDS databases, and more. Here are some examples of how to use AWS CLI −

Example 1: List all S3 buckets

To list all S3 buckets using AWS CLI, type following command −

aws s3 ls

This command will list all S3 buckets in your account.

Example 2: Create an EC2 instance

To create an EC2 instance using AWS CLI, type following command −

aws ec2 run-instances --image-id ami-0c94855ba95c71c99 --count 1 --instance-type t2.micro --key-name my-key-pair --security-group-ids sg-1234567890

This command will create an EC2 instance with specified parameters.

Example 3: Delete an S3 bucket

To delete an S3 bucket using AWS CLI, type following command −

aws s3 rb s3://my-bucket --force

This command will delete specified S3 bucket.

Conclusion

In this article, we discussed how to install AWS CLI on Linux. We covered two popular methods, using pip and package manager, and also discussed how to configure AWS CLI and use it to manage your AWS resources. AWS CLI is a powerful tool that allows you to automate your AWS infrastructure and manage your resources using command line interface. With AWS CLI, you can easily create, update, and delete your AWS resources, making it an essential tool for any AWS user.

Updated on: 24-Mar-2023

862 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements