python3 -m awscli --version
As shown in the image above, When we install AWS CLI as a python module, it does not always install the latest version. The latest version of AWS CLI is 2.7, whereas the above method installs version 1.25. Therefore, it is recommended to use the official method, which is discussed below.
Installing AWS CLI using the official AWS distribution points
The AWS CLI can also be installed using the official distribution points. We prefer this method as it is an official method and will always install the latest version of AWS CLI.
To install AWS CLI on Ubuntu, download the official AWS installation file by executing the following command:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Alternatively, you can also download the installation file using the following link:
If the curl command is not installed on your system, execute the following command to install curl:
sudo apt install curl
Now, extract the zipped installation file using the file manager or by using the unzip command:
The above command extracts the installation file in the active directory and creates a new directory named aws in the current directory.
Then, install the AWS CLI by executing the following command:
That’s all! AWS CLI has been installed on your system successfully.
To check the current version of AWS CLI, execute the following command:
Update AWS CLI to the latest version
If you already have AWS Command Line Interface on your system, you can update it to the latest version using the following commands. When the AWS CLI is installed, the files are stored at the location /usr/local/aws-cli, and a symbolic link is created at the location /usr/local/bin. To update the files at both locations, execute the following command:
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
To confirm whether it has been installed to the latest version, execute the following command to check the current version installed:
Configure AWS Command Line Interface
To run the AWS CLI, you should have an AWS account, an IAM user account, and an IAM access key and secret key. They are listed below with the links to configure.
- If you have an AWS account, skip this point. If not, create an AWS account by clicking here. Complete the sign-up procedure. The account will be created in a few minutes, but the process takes 24 hours.
- Create an IAM user account by signing as the root AWS user in the IAM console and adding a new user other than the root user. Use this account in the AWS CLI rather than the root user for your account security.
- With the IAM user account created above, create an access key ID and secret access key, which are used to sign programmatic requests. Store the access keys at the creation time as they cannot be recovered later.
For more details, you can refer to the official AWS guide by clicking here.
Uninstalling AWS CLI
In case you need to uninstall the AWS Command Line Interface, execute the following command in a terminal window:
sudo apt remove --purge awscli
So, we discussed AWS CLI and how to install it on Ubuntu 22.04LTS. We covered almost everything about AWS CLI with links to the official documentation. If you liked the article or if we missed anything, please let me know in the comment section below.
We have no tolerance for comments containing violence, racism, profanity, vulgarity, doxing, or discourteous behavior. Thank you for partnering with us to maintain fruitful conversation.