Last updated on July 29th, 2024 at 05:19 am
Amazon Web Services (AWS) is one of the most popular cloud-based services used by millions of users and organizations. It provides a vast range of services to run websites and apps on the internet. However, it can be difficult to manage them all from one place. AWS CLI is a command line tool that allows you to manage the different AWS services from one place, using command line. It also allows you to automate AWS management using scripts. Here is how to install AWS CLI on Linux. You can use these steps to install AWS CLI on Ubuntu, CentOS. We will also look at how to check if AWS CLI is installed and how to access AWS CLI.
What is AWS CLI
AWS CLI is a command line tool to provide a single interface to interact with and manage all your AWS services from one place. It allows you to view and control different services in your AWS account. You can use AWS to connect to various AWS services, automate them using scripts, manage additional user profiles and make API calls. It is very useful for system administrator to easily manage their AWS Services from one tool.
How to Install AWS CLI on Linux
Here are the command to install AWS CLI on different Linux systems.
Ubuntu/ Debian Linux
You can easily install AWS CLI on Debian/Ubuntu systems using apt package manager.
$ sudo apt install awscli
Fedora and CentOS
DNF package manager allows you to install AWS CLI on Fedora and CentOS>=8 systems.
$ sudo dnf install awscli
CentOS 7 and Red hat Linux
You can install AWS CLI on RHEL and CentOS <=7 systems.
$ sudo yum install awscli
Install Using Python
You can also use Python’s PIP package manager to install AWS CLI. Here is the command to install PIP, if not present already.
$ sudo apt-get install python3-pip
Once you have installed PIP, you can install AWS CLI with the following command.
$ sudo pip install awscli
Install Using Source
You can also download and install AWS CLI from source. Here is the command to download CLI version 2.
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" \
-o "awscliv2.zip"
Unzip the downloaded file.
$ unzip awscliv2.zip
Install the extracted file.
$ sudo ./aws/install
Once you have installed the client, you can verify installation with the following command.
$ awscli --version
Next, we will look at how to configure AWS CLI.
Bonus Read : Top AWS Cost Optimization Best Practices
How to Configure AWS CLI
Here are the steps to access and configure AWS CLI for use.
1. Go to AWS Security Credentials
2. Expand Access keys (access key ID and secret access key)
3. Click Create New Access Key
4. Copy the access key ID and secret access key to a secure location.
5. Open terminal and run the following command
$ aws configure
6. You will see the following prompt. Enter AWS Access Key ID and Secret Access Key. Also specify region name of your EC2 instances, and output format (text/json) of your commands.
AWS Access Key ID [None]: ABCDEFXXXXXXXXDKKDFJ AWS Secret Access Key [None]: 5jksdf9sdfjsdSKSDKSJDFskjf8KDfkfjkFKD Default region name [None]: us-east-1 Default output format [None]:
That’s it! You have installed and configured AWS CLI on Linux.
Bonus Read : How to Enable GZIP Compression in NGINX
AWS CLI Commands
Here are some handy AWS CLI commands for your reference.
Here’s the command to get a list of all available commands with their use, in AWS CLI. You can also use this command to check if AWS is installed.
$aws help
List all EC2 instances in AWS
$ aws ec2 describe-instances
List EC2 instances from specific zone
$ aws ec2 describe-instances --region=us-east-1
Get status of specific EC2 instance (replace your_instance_id below with your instance ID)
$ aws ec2 describe-instances --instance-id your_instance_id
List S3 buckets
$ aws s3 list
Conclusion
Hopefully, this article will help you download, configure, and access AWS CLI to manage your Amazon Web Services account. We have learnt 5 different ways to install AWS CLI on Linux. You can use any of them as per your convenience. AWS CLI is a great way to connect to your AWS account and interact with your services using one tool.
Ubiq makes it easy to visualize data and monitor in real-time dashboards. Try it for free.
Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.