Installing AWS CLI on Ubuntu 22.04 LTS

Introduction

AWS CLI stands for Amazon Web Services Command Line Interface. It is a command-line tool provided by Amazon Web Services (AWS) that allows developers, system administrators, and other users to interact with AWS services and manage their resources from a command-line interface.

By using AWS CLI, users can automate their AWS workflows, write scripts, and incorporate AWS commands into their own applications or development processes. It provides a powerful and efficient way to manage AWS resources programmatically and integrate them with other tools and services.

In this post, We will show you show to install and configure AWS CLI on Ubuntu 22.04 LTS

Prerequisites

To install the AWS Command Line Interface (CLI) on your computer, you’ll need to ensure that your system meets the following hardware requirements:

  • Processor: AWS CLI can be installed on systems with x86-64 architecture processors or ARM processors. Most modern computers meet this requirement.
  • RAM: The AWS CLI itself doesn’t have strict RAM requirements. However, keep in mind that running AWS CLI commands may consume memory, especially when working with large amounts of data or running resource-intensive operations. A minimum of 1 GB of RAM is generally recommended, but having more RAM will provide better performance.
  • Disk Space: AWS CLI installation requires only a small amount of disk space. The exact space required depends on the operating system, but typically it ranges from 100 MB to 200 MB. It’s also important to note that the AWS CLI uses additional disk space to store configuration files, command history, and downloaded data.
  • Operating System: AWS CLI supports various operating systems, including Windows, macOS, and Linux. Make sure your system meets the requirements of the specific operating system you are using.
  • Network Connectivity: AWS CLI requires an active internet connection to interact with the AWS services. Ensure that your system has internet access, as it is necessary to download and update the AWS CLI.

These are the general hardware requirements for installing the AWS CLI. However, it’s always a good practice to refer to the official AWS CLI documentation for any specific hardware or software requirements for the version you are installing, as they may vary slightly over time.

Step 1: Run System Updates

Update the package lists and upgrade existing packages by running the following commands:

sudo apt-get update && sudo apt-get upgrade -y

Step 2: Installing AWS CLI

Install the AWS CLI using the Python package manager (pip). If pip is not installed on your system, you can install it using the following command:

To Install Python3 PIP.

sudo apt-get install python3-pip -y 

Once pip is installed, you can install the AWS CLI by running the following command:

sudo pip3 install awscli

Step 3: Validate AWS Version

After the installation completes, you can verify that AWS CLI is installed by running the following command:

aws --version

This command should display the version of AWS CLI if the installation was successful.

Step 4: Configure AWS CLI

you need to configure AWS CLI with your AWS credentials. You can do this by running the following command:

aws configure

This command will prompt you to enter your AWS Access Key ID, AWS Secret Access Key, default region, and default output format. Make sure to provide the correct information based on your AWS account.

You will be prompted to enter your AWS Access Key ID and Secret Access Key. You can obtain these credentials from the AWS Management Console.

  • Access Key ID: The access key for your AWS account.
  • Secret Access Key: The secret key for your AWS account.

Make sure to keep your credentials secure. If you don’t have an Access Key ID and Secret Access Key, you can create a new pair in the AWS Management Console under “IAM” (Identity and Access Management).

You’ll also be prompted to enter the default region name. This is the AWS region code, such as “us-east-1” or “eu-west-1”. Enter the code for the region you want to use.

Finally, you’ll be prompted to enter the default output format. You can choose from several formats such as “json”, “text”, or “table”. Enter your preferred format.

After completing these steps, your AWS CLI will be configured with the provided credentials, default region, and output format. You can now use the AWS CLI to interact with AWS services using the configured credentials.

Step 5: Testing AWS CLI Commands

Once you’ve configured the AWS CLI with your credentials, you can test it by running some basic S3 (Simple Storage Service) commands. Here are a few examples:

List S3 buckets

aws s3 ls

This command will list all the S3 buckets in your AWS account.

Create an S3 bucket

aws s3 mb s3://your-unique-bucket-name

Replace “your-unique-bucket-name” with a globally unique name for your bucket.

Upload a file to an S3 bucket

aws s3 cp your-local-file.txt s3://your-unique-bucket-name/

Replace “your-local-file.txt” with the path to the file on your local machine.

List objects in an S3 bucket

aws s3 ls s3://your-unique-bucket-name/

This command will list the objects (files) in the specified S3 bucket.

Download a file from an S3 bucket

aws s3 cp s3://your-unique-bucket-name/your-remote-file.txt .

Replace “your-remote-file.txt” with the name of the file in your S3 bucket, and the dot at the end represents the current directory where the file will be downloaded.

Delete an object from an S3 bucket

aws s3 rm s3://your-unique-bucket-name/your-remote-file.txt

Replace “your-remote-file.txt” with the name of the file you want to delete.

Delete an S3 bucket

aws s3 rb s3://your-unique-bucket-name

This command will delete the specified S3 bucket. Make sure the bucket is empty before attempting to delete it. Remember to replace placeholders like “your-unique-bucket-name” and “your-local-file.txt” with your actual values.

These are basic examples, and the AWS CLI provides a wide range of commands for interacting with various AWS services. You can find more information and options in the official AWS CLI documentation.

Step 6: Uninstalling AWS CLI

To uninstall the AWS Command Line Interface (CLI) using pip, you can follow these steps, Run the following command to uninstall the AWS CLI using pip.

pip3 uninstall awscli

You may be prompted to confirm the uninstallation. Enter ‘y’ or ‘yes’ to proceed with the uninstallation, Wait for the uninstallation process to complete. Pip will remove the AWS CLI package from your system.

After these steps, the AWS CLI should be successfully uninstalled from your system. It’s a good practice to verify the uninstallation by running the following command to check if the AWS CLI is no longer available:

aws --version

If the command returns an error or does not display the AWS CLI version, it indicates that the uninstallation was successful.

Note: If you installed the AWS CLI using a package manager specific to your operating system (e.g., Homebrew on macOS), you should use the appropriate method to uninstall it. The above steps are specifically for uninstalling the AWS CLI installed via pip.

Conclusion

Once you have completed these steps, the AWS CLI will be installed and configured on your Ubuntu 22.04 LTS system, and you will be able to use it to interact with AWS services from the command line.

Author

Installing AWS CLI on Ubuntu 22.04 LTS

3 thoughts on “Installing AWS CLI on Ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top