Installing AWS CLI on Linux

Amazon Web Services (AWS) is one of the most popular cloud computing platforms in the 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 the terminal or shell. In this article, we will discuss how to install AWS CLI on Linux, including various methods and configuration steps.

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 the terminal and type the following command

python3 --version

This command will return the 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 the next step.

Step 2: Install AWS CLI

Once you have confirmed that Python is installed on your system, you can proceed with the installation of AWS CLI. You can install AWS CLI on Linux using several methods, such as using pip, package manager, or downloading the 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 the terminal and type the following command to install pip

sudo apt-get install python3-pip

Step 2 Once pip is installed, type the following command to install AWS CLI

sudo pip3 install awscli

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

aws --version

This command will display the 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 the package manager to install AWS CLI on Linux. The following steps show you how to install AWS CLI using the package manager.

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

sudo apt-get update

Step 2 Once the package manager is updated, type the following command to install AWS CLI

sudo apt-get install awscli

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

aws --version

This command will display the 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. The following steps show you how to configure AWS CLI.

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

aws configure

This command will prompt you to enter the 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 the AWS Management Console and navigate to the IAM service. Create a new user or use an existing user and generate the Access Key ID and Secret Access Key.

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

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

Step 5 Finally, enter the default output format. The default output format is json, but you can choose any other format, such as yaml or text.

Step 6 Once you have entered all the 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.

Using AWS CLI Examples

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 the 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 the 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 the specified parameters.

Example 3: Delete an S3 bucket

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

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

This command will delete the specified S3 bucket.

Troubleshooting

Issue Solution
Command not found: aws Ensure AWS CLI is installed and /usr/local/bin is in your PATH
Permission denied during installation Use sudo with installation commands
Unable to locate credentials Run aws configure to set up your credentials
Invalid region error Verify region name in AWS documentation and reconfigure

Conclusion

AWS CLI is a powerful tool that allows you to automate your AWS infrastructure and manage your resources using the command line interface. With proper installation and configuration, you can easily create, update, and delete your AWS resources, making it an essential tool for any AWS user.

Updated on: 2026-03-17T09:01:38+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements