How to install AWS CLI on Linux (AlmaLinux)
In today's technologically advanced world, the Amazon Web Services Command Line Interface (AWS CLI) is an essential tool for cloud supporters and professionals. The AWS CLI is a collection of open-source command-line tools for working with Amazon Web Services (AWS). It allows users to control and customize AWS services using the command line.
AWS CLI allows you to create and manage EC2 instances, S3 buckets, IAM users, and other operations easily and quickly. The AWS CLI helps to improve operational efficiency by easing cloud management operations and promoting automation. This article will guide readers through installing AWS CLI on AlmaLinux, providing a practical method for using AWS services in this Linux distribution. Whether an experienced cloud user or new to AWS, learning and using the AWS CLI is important for managing the complexities of cloud computing with regard to AWS ressources.
Key points of this article
The reader of this post will learn about following topic areas:
- Installing AWS CLI on install Linux step-by-step
- Using the install script or PIP when installing AWS CLI
- Updating AWS CLI
- Uninstalling AWS CLI
- Amazon Web Services Command Line Interface (AWS CLI) commands
- Leveraging seamless integration with AWS CLI to unlock endless possibilities
How to install AWS CLI on install Linux step-by-step
To install AWS CLI on Linux (AlmaLinux), please follow the steps given below after completing the setup items for the prerequisites.
Prerequisites
- Operating system and version — AlmaLinux OS 8.
- Make sure you have proper system permissions in terms of root or sudo access to install the AWS CLI.
Step #1. Update your AlmaLinux system
Before installing AWS CLI, you must update the OS to refresh the repository's cache and apply the most recent changes. To update the AlmaLinux, issue the following command:
sudo dnf update
Step #2. Install AWS CLI
You can install AWS CLI on Linux (AlmaLinux) using the install script or PIP. The two options are documented in the next sections.
Option 2.1: Install AWS CLI on Linux using the install script
2.1.1. Download the installation file
To download the installation file, use any of the following methods.
2.1.1.a. Using the curl command to download the installation file
One method is the use of the curl command:
sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
The -o option provides the file name where the downloaded package will be written. The options provided in the following example command are to copy the downloaded file to the current directory with the local name awscliv2.zip.
Here is the output:
]# sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 57.2M 100 57.2M 0 0 233M 0 --:--:-- --:--:-- --:--:-- 233M
2.1.1.b. Downloading the installation file from the URL
To download the installation file with your browser, use the following URL:
2.1.2. Extract the downloaded installation file
To extract the downloaded installation file awscliv2.zip, run the following command:
sudo unzip awscliv2.zip
If you're downloading the installation file from the URL, run the following command to extract it:
sudo unzip awscli-exe-linux-x86_64.zip
2.1.3. Install AWS CLI using the install script
To Install AWS CLI using the install script, run the following command:
sudo ./aws/install
The installation command executes an install file in the newly unzipped aws directory. The files are automatically installed to /usr/local/aws-cli, and a symbolic link is made in /usr/local/bin. The command includes sudo, which grants write permissions to those directories.
2.1.4. Verify the AWS CLI version
To verify the AWS CLI version, run the following command:
aws --version
Here is the output:
]# aws --version
aws-cli/2.15.10 Python/3.11.6 Linux/4.18.0-513.5.1.el8_9.x86_64 exe/x86_64.almalinux.8 prompt/off
Option 2.2: Install AWS CLI on Linux using PIP
2.2.1. Install Python and PIP
To Python3 and PIP3, run the following command:
sudo dnf install python3 python3-pip
Here is the output:
]# sudo dnf install python3 python3-pip
Last metadata expiration check: 0:15:12 ago on Sun 14 Jan 2024 05:21:38 AM UTC.
Dependencies resolved.
==============================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================================================================================
Installing:
python3-pip noarch 9.0.3-23.el8 appstream 19 k
python36 x86_64 3.6.8-38.module_el8.9.0+3700+efebe 9fd appstream 18 k
Installing dependencies:
python3-setuptools noarch 39.2.0-7.el8 baseos 162 k
Enabling module streams:
python36 3.6
Transaction Summary
==============================================================================================================================================================================================================================================
Install 3 Packages
Total download size: 199 k
Installed size: 466 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): python36-3.6.8-38.module_el8.9.0+3700+efebe9fd.x86_64.rpm 1.7 MB/s | 18 kB 00:00
(2/3): python3-pip-9.0.3-23.el8.noarch.rpm 1.4 MB/s | 19 kB 00:00
(3/3): python3-setuptools-39.2.0-7.el8.noarch.rpm 7.6 MB/s | 162 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 944 kB/s | 199 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : python3-setuptools-39.2.0-7.el8.noarch 1/3
Installing : python3-pip-9.0.3-23.el8.noarch 2/3
Installing : python36-3.6.8-38.module_el8.9.0+3700+efebe9fd.x86_64 3/3
Running scriptlet: python36-3.6.8-38.module_el8.9.0+3700+efebe9fd.x86_64 3/3
Verifying : python3-setuptools-39.2.0-7.el8.noarch 1/3
Verifying : python3-pip-9.0.3-23.el8.noarch 2/3
Verifying : python36-3.6.8-38.module_el8.9.0+3700+efebe9fd.x86_64 3/3
Installed:
python3-pip-9.0.3-23.el8.noarch python3-setuptools-39.2.0-7.el8.noarch python36-3.6.8-38.module_el8.9.0+3700+efebe 9fd.x86_64
Complete!
2.2.2. Install AWS CLI on Linux using PIP
To install AWS CLI on Linux (AlmaLinux) using PIP, run the following command:
sudo pip3 install awscli --upgrade --user
Regarding the above command syntax, here are more details:
- --upgrade — ensures that the latest version is installed, upgrading any existing version.
- --user — installs the package for the current user only, avoiding the need for elevated privileges.
Here is the output:
]# sudo pip3 install awscli --upgrade --user
Collecting awscli
Downloading https://files.pythonhosted.org/packages/6c/48/8cf68d31f3f8606904acc4d98965a2c020acd5e1b9a821b8a7fafdbbc81a/awscli-1.24.10-py3-none-any.whl (3.9MB)
100% |████████████████████████████████| 3.9MB 329kB/s
Collecting s3transfer<0.6.0,>=0.5.0 (from awscli)
Downloading https://files.pythonhosted.org/packages/7b/9c/f51775ebe7df5a7aa4e7c79ed671bde94e154bd968aca8d65bb24aba0c8c/s3transfer-0.5.2-py3-none-any.whl (79kB)
100% |████████████████████████████████| 81kB 7.2MB/s
Collecting docutils<0.17,>=0.10 (from awscli)
Downloading https://files.pythonhosted.org/packages/81/44/8a15e45ffa96e6cf82956dd8d7af9e666357e16b0d93b253903475ee947f/docutils-0.16-py2.py3-none-any.whl (548kB)
100% |████████████████████████████████| 552kB 2.1MB/s
Collecting PyYAML<5.5,>=3.10 (from awscli)
Downloading https://files.pythonhosted.org/packages/7a/5b/bc0b5ab38247bba158504a410112b6c03f153c652734ece1849749e5f518/PyYAML-5.4.1-cp36-cp36m-manylinux1_x86_64.whl (640kB)
100% |████████████████████████████████| 645kB 1.7MB/s
Collecting colorama<0.4.5,>=0.2.5 (from awscli)
Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl
Collecting botocore==1.26.10 (from awscli)
Downloading https://files.pythonhosted.org/packages/09/b8/794e0bd260198538ded90c26b353ddb632eab01950d4e7e2e2b8ee510d12/botocore-1.26.10-py3-none-any.whl (8.8MB)
100% |████████████████████████████████| 8.8MB 111kB/s
Collecting rsa<4.8,>=3.1.2 (from awscli)
Downloading https://files.pythonhosted.org/packages/e9/93/0c0f002031f18b53af7a6166103c02b9c0667be528944137cc954ec921b3/rsa-4.7.2-py3-none-any.whl
Collecting python-dateutil<3.0.0,>=2.1 (from botocore==1.26.10->awscli)
Downloading https://files.pythonhosted.org/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247kB)
100% |████████████████████████████████| 256kB 3.6MB/s
Collecting urllib3<1.27,>=1.25.4 (from botocore==1.26.10->awscli)
Downloading https://files.pythonhosted.org/packages/b0/53/aa91e163dcfd1e5b82d8a890ecf13314e3e149c05270cc644581f77f17fd/urllib3-1.26.18-py2.py3-none-any.whl (143kB)
100% |████████████████████████████████| 153kB 2.6MB/s
Collecting jmespath<2.0.0,>=0.7.1 (from botocore==1.26.10->awscli)
Downloading https://files.pythonhosted.org/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl
Collecting pyasn1>=0.1.3 (from rsa<4.8,>=3.1.2->awscli)
Downloading https://files.pythonhosted.org/packages/d1/75/4686d2872bf2fc0b37917cbc8bbf0dd3a5cdb0990799be1b9cbf1e1eb733/pyasn1-0.5.1-py2.py3-none-any.whl (84kB)
100% |████████████████████████████████| 92kB 9.3MB/s
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore==1.26.10->awscli)
Downloading https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, urllib3, jmespath, botocore, s3transfer, docutils, PyYAML, colorama, pyasn1, rsa, awscli
Successfully installed PyYAML-5.4.1 awscli-1.24.10 botocore-1.26.10 colorama-0.4.4 docutils-0.16 jmespath-0.10.0 pyasn1-0.5.1 python-dateutil-2.8.2 rsa-4.7.2 s3transfer-0.5.2 six-1.16.0 urllib3-1.26.18
2.2.3. Verify the AWS CLI version
To verify the AWS CLI version, run the following command:
aws --version
Here is the output:
]# aws --version
aws-cli/2.15.10 Python/3.11.6 Linux/4.18.0-513.5.1.el8_9.x86_64 exe/x86_64.almalinux.8 prompt/off
2.2.4. Configure AWS CLI
You can use the command line to authenticate with AWS and specify your credentials for various AWS services. Credential profiles control AWS credentials. Credential profiles contain your Account Name, AWS Access Key ID, and Secret Access Key. You will be prompted to input credentials when you run the AWS CLI command. You can manage your credentials using the AWS dashboard or the command line.
To initiate the AWS CLI configuration process, run the following command:
sudo aws configure
Then, follow the prompts to provide your output format, default region, Secret Access Key, and AWS Access Key ID,.
Here is the output:
]# sudo aws configure
AWS Access Key ID [None]: ALISIOS DNN7 EXAMPLE
AWS Secret Access Key [None]: olorUnFEMI/K7MDENG/bF RfiC EXAMPLES
Default region name [None]: us-east-1
Default output format [None]: json
2.2.5. Test the AWS CLI
After successfully authenticating and connecting your AWS account, you can run any AWS CLI commands to ensure everything works — for example:
sudo aws s3 ls
Here is the output:
]# sudo aws s3 ls
2024-01-14 11:00:00 123456789 sample-s3-bucket
2024-01-14 12:00:00 987654321 test-bucket
How to update AWS CLI
To update the AWS CLI on Linux (AlmaLinux), run the following command:
sudo pip3 install awscli --upgrade --user
How to uninstall AWS CLI
To uninstall AWS CLI via PIP, run the following command:
sudo pip3 uninstall awscli
Here is the output:
]# sudo pip3 uninstall awscli
Uninstalling awscli-1.24.10:
---
---
Proceed (y/n)? y
Successfully uninstalled awscli-1.24.10
You may need to remove the installation directory if you installed AWS CLI with the official install script. The default installation directory is typically /usr/local/aws-cli:
sudo rm -r /usr/local/aws-cli
This command recursively removes the AWS CLI installation directory.
If you symlinked AWS CLI binaries to a directory in your PATH, you may need to remove the symlinks:
sudo rm -r /usr/local/bin/aws
This command removes the symlink to the AWS CLI binary.
Always check for any custom installation paths or options you may have used during the installation process and modify the commands accordingly.
Amazon Web Services Command Line Interface (AWS CLI) commands
Here are some important and commonly used AWS CLI commands:
AWS IAM (Identity and Access Management)
To create a new IAM user, issue this command:
aws iam create-user --user-name <username>
To create an access key, here is the command to use:
aws iam create-access-key --user-name <username>
To list IAM users, run the following command:
aws iam list-users
AWS S3 (Simple Storage Service)
To list S3 buckets, the command would be:
aws s3 ls
To list objects in a bucket, the command is as follows:
aws s3 ls s3://<bucket-name>
To upload a file to S3, run the cp command:
aws s3 cp <local-file> s3://<bucket-name>/<remote-file>
AWS EC2 (Elastic Compute Cloud)
List EC2 instances:
aws ec2 describe-instances
Create a new EC2 instance:
aws ec2 run-instances --image-id <ami-id> --instance-type <instance-type> --key-name <key-pair-name>
Terminate an EC2 instance:
aws ec2 terminate-instances --instance-ids <instance-id>
These commands provide a starting point for interacting with some AWS services. For more details and options, refer to the official AWS CLI documentation.
The article, Liquid Web vs. Amazon Web Services (AWS), compares the two services.
Empower your AlmaLinux Server — leveraging seamless integration with AWS CLI to unlock endless possibilities
Getting going with the AWS CLI on the AlmaLinux distribution of Linux is a straightforward process that enhances the system's capabilities for managing AWS resources. Following this article, you can seamlessly set up the CLI, enabling efficient interaction with AWS services and facilitating streamlined command-line operations. This integration empowers AlmaLinux users to leverage the full potential of AWS cloud services in their infrastructure.
Liquid Web offers exceptional support and managed hosting services for a seamless installation of AWS CLI on AlmaLinux. Liquid Web's comprehensive assistance improves the installation process, providing a secure basis for AWS resource management. This service from Liquid Web allows you to focus on your business operations while maximizing the benefits of AWS integration on AlmaLinux. Cloud Studio by Liquid Web offers a more simplified and reliable cloud service, offering a better alternative to Azure and AWS. Liquid Web's Cloud Studio may be better for developers seeking more flexible and reliable cloud services.
Related Articles:
![Avatar for Mohammed Noufal](/static/087d08032a50c4c92d6876b3acec4052/9ca7a/78f79aa1903969121f83a04318ddb54c.png)
About the Author: Mohammed Noufal
Mohammed Noufal is a B.Tech graduate with a decade of experience in server administration and web hosting. He is a father to two daughters and finds fulfillment in their growth. In his free time, he enjoys blogging, sharing experiences, and listening to music. With a strong technical background, family commitment, and creative outlets, he represents a well-rounded life journey.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
Innovative armor — exploring ThreatDown’s impact on cyber defense
Read ArticleUsing a Cloudflare Argo Tunnel with load balancing
Read ArticleControlling PHP settings with a custom php.ini file
Read ArticleLinux dos2unix command syntax — removing hidden Windows characters from files
Read ArticleChange cPanel password from WebHost Manager (WHM)
Read Article