The AWS Command Line Interface (CLI) is a versatile and powerful tool that provides developers, system administrators, and DevOps professionals the ability to manage AWS resources directly from the command line. It allows users to interact with AWS services efficiently, without needing to rely on the AWS Management Console. By using the AWS CLI, you can execute commands to control numerous AWS services, automate routine tasks using scripts, and manage cloud infrastructure with greater precision and speed. Whether you are launching instances, managing S3 buckets, or configuring AWS services, the AWS CLI can significantly enhance productivity and streamline cloud operations. This comprehensive guide will walk you through each step of installing the AWS CLI on Ubuntu 24.04, ensuring that you have all the necessary tools and knowledge to efficiently manage your cloud environment.
Update Your Package List
The first step is to update your package list to ensure you have the latest versions of all available packages and their dependencies:
sudo apt update
This command updates the local package index, making sure your system is aware of the latest software versions and security patches available.
Install Required Dependencies
The AWS CLI requires Python, and you will also need the unzip
utility to extract the installation files. Use the following command to install both:
sudo apt install -y python3 python3-pip unzip
Here, -y
automatically answers “yes” to prompts during the installation, saving time and making the process more seamless.
Download the AWS CLI Installation File
Next, download the latest version of the AWS CLI directly from the official AWS website. You can use curl
to accomplish this:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
This command downloads the AWS CLI ZIP file to your current directory.
Extract the ZIP File
After the download is complete, you need to extract the contents of the ZIP file using the unzip
command:
unzip awscliv2.zip
This will extract the installation files into a directory named aws
.
Install the AWS CLI
Once the files are extracted, navigate into the newly created aws
directory and run the installation script:
sudo ./aws/install
This command installs the AWS CLI to your system. You may need root privileges for the installation, which is why sudo
is used.
Verify the Installation
To ensure the AWS CLI has been installed correctly, you can check its version by running the following command:
aws --version
You should see an output similar to this:
aws-cli/2.x.x Python/3.x.x Linux/4.x.x-xx-generic exe/x86_64.ubuntu.24.04
This output indicates that AWS CLI version 2.x.x is installed and ready for use.
Configure the AWS CLI
Once the installation is complete, it’s time to configure the AWS CLI with your credentials and default settings. Run the command below:
aws configure
You will be prompted to provide the following information:
- AWS Access Key ID: Enter your access key ID here.
- AWS Secret Access Key: Enter your secret access key here.
- Default region name: Specify your preferred AWS region (e.g.,
us-west-2
). - Default output format: Choose your desired output format (
json
,text
, oryaml
). Thejson
format is a common choice for ease of parsing.
This configuration step helps set up default credentials and region settings for AWS commands, making it easier to interact with your AWS environment.
Clean Up Installation Files (Optional)
Once you have installed and configured the AWS CLI, you can clean up the installation files to free up some space:
rm -rf awscliv2.zip aws
This command removes the downloaded ZIP file and the extracted directory.
You have successfully installed and configured the AWS CLI on Ubuntu 24.04. With the AWS CLI, you can efficiently manage your cloud infrastructure, automate routine tasks, and perform various operations like launching instances, managing S3 buckets, and configuring AWS services.
For more detailed information about AWS CLI commands and options, refer to the AWS CLI User Guide. The flexibility of the AWS CLI will help you make the most of your AWS environment and improve your productivity in managing cloud resources.
Discussion about this post