Installing AWS CLI on Ubuntu: A Step-by-Step Guide

Welcome to this comprehensive guide on how to install the AWS CLI on Ubuntu Linux. The AWS Command Line Interface (CLI) is a unified tool that allows you to manage your AWS services from the terminal session on your own client. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts. This tutorial is designed for developers and system administrators looking for ways to automate or manage AWS services.

In this tutorial you will learn:

  • How to install AWS CLI using Snap
  • How to verify the installation by checking the AWS CLI version
  • How to configure AWS CLI
Installing AWS CLI on Ubuntu: A Step-by-Step Guide
Installing AWS CLI on Ubuntu: A Step-by-Step Guide
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux
Software Snap Package Manager
Other AWS account and credentials
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Installing AWS CLI on Ubuntu

Installing AWS CLI on Ubuntu Linux is straightforward and can be accomplished using the Snap package manager. Snap provides an easy-to-install package that includes all the necessary dependencies, ensuring that the AWS CLI runs smoothly on your system.

  1. Install AWS CLI using Snap: Start by installing the AWS CLI using Snap. This method is preferred because it isolates the installation from other system software and ensures that you have the latest version.
    $ sudo snap install aws-cli --classic

    This command installs the AWS CLI from the Snap store and makes it available system-wide. The --classic flag is required because the AWS CLI needs to access system files and resources not typically accessible in a strictly confined snap.



  2. Verify the Installation: After installation, it’s a good practice to verify that the AWS CLI has been installed correctly by checking its version.
    $ aws --version

    This command outputs the version of the AWS CLI installed, confirming that the installation was successful.

  3. Configure AWS CLI: With the AWS CLI installed, the next step is to configure it with your credentials.
    $ aws configure

    This command prompts you for your AWS Access Key ID, Secret Access Key, region, and output format, which are necessary for the AWS CLI to communicate with AWS services.

    aws cli - Install, version check and configuration
    aws cli – Install, version check and configuration

Troubleshooting

If you encounter issues when trying to install AWS CLI using the package manager with the command:

$ sudo apt install awscli
[sudo] password for linuxconfig:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package awscli is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

This indicates that the AWS CLI package may not be available in your current repositories or has been replaced. A common solution to this problem is to use Snap to install AWS CLI, as Snap packages are often more up-to-date and can bypass issues related to missing or obsolete packages in the repository. Proceed with the Snap installation method as previously outlined:

$ sudo snap install aws-cli --classic

Conclusion

By following these steps, you have successfully installed and configured the AWS CLI on Ubuntu Linux. This tool will now enable you to manage your AWS services directly from the command line, facilitating automation and efficient management of your cloud resources. Remember, if you encounter issues with the package availability using traditional methods, using Snap ensures a smooth installation process.