Installing and Configuring AWS CLI on Ubuntu

Ready to use Amazon Web Services (AWS) CLI on Ubuntu 20.04 or 22.04? Follow this guide for a quick walkthrough – from updating packages to running AWS CLI commands. Let’s dive in!

Updating Local Packages on Ubuntu

Before we begin, it’s essential to ensure that your local packages are up-to-date. Execute the following command in your terminal:

# update local packages
sudo apt-get update
Ubuntu Apt Get Update

This ensures that your Ubuntu system has the latest package information.

Installing AWS CLI on Ubuntu

Now that your local packages are updated, let’s install AWS CLI using the following command:

# install aws cli ubuntu
sudo apt-get install awscli
Ubuntu Install AWS CLI

This command fetches and installs the AWS CLI, bringing the power of AWS to your fingertips.

Check Installed AWS CLI Version

Once the installation is complete, verify the installed AWS CLI version by running:

# check installed aws cli version
aws --version
Ubuntu Check AWS CLI Version

This ensures that the correct version is installed on your system.

Configure Your AWS Profile

Before you can unleash the full potential of AWS CLI, you need to configure your AWS profile. Use the following command to set up your profile:

# configure aws cli profile
aws configure

This command prompts you to enter your Access Key ID, Secret Access Key, default region, and output format. Retrieve your Access Key ID and Secret Access Key from the AWS IAM Console.

For this blog post, here’s a small exploration of the new AWS Configuration files:

# explore aws configuration files
cd .aws/
ls -lia
12666373952234567 drwxr-xr-x 1 root root 4096 Jan 23 20:29 .
 3659174697310898 drwx------ 1 root root 4096 Jan 23 20:19 ..
16044073672764147 -rw------- 1 root root   43 Jan 23 20:29 config
35747322042278663 -rw------- 1 root root   68 Jan 23 20:29 credentials
cat config
[default]
region = eu-west-2
output = json
cat credentials
[default]
aws_access_key_id = 11223344
aws_secret_access_key = 1234
AWS Configure and Explore AWS Files

Running AWS CLI Commands

With your AWS profile configured, you can start executing AWS CLI commands. Here’s an example that lists all buckets in your AWS account with the prefix “pw-“:

# list buckets in aws account with name prefix
aws s3 ls s3://pw-*
AWS S3 API List Buckets

Feel free to explore the vast array of AWS CLI commands available to manage and interact with your AWS resources.

Leave a Reply

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