How to Install AWS CLI on Ubuntu[17 Proven Steps]

Written by

Reviewed by

Last updated: July 26, 2023

Expert verified

SVG Image

TL;DR

To install AWS CLI on Ubuntu, you can follow these steps:

  1. Check Ubuntu version: lsb_release -a - Run this command in the Terminal to check the version of Ubuntu you are using. It will display the specific release information of your Ubuntu distribution.
  2. Update package list: sudo apt update - Execute this command to update the package list on your Ubuntu system. It ensures that you have the latest information about available packages and their versions.
  3. Install Python: sudo apt install python3 - Use this command to install Python, a widely used programming language required for running AWS CLI and its dependencies. Python provides the foundation for AWS CLI’s functionality.
  4. Install AWS CLI using Pip: pip3 install awscli --upgrade --user - This command installs AWS CLI using Pip, the package installer for Python. Pip fetches the latest version of AWS CLI and installs it specifically for the current user, upgrading any existing installation if necessary.

To configure AWS CLI after installation, generate AWS access credentials through the AWS Management Console, then use the aws configure command in the Terminal to set up AWS CLI with your access key ID, secret access key, default region, and output format. Be aware of common installation errors like “Command not found,” “Permission denied,” “Could not connect to the Internet,” and “Version conflict” to troubleshoot and ensure a successful installation.

Explore the step-by-step method to install AWS CLI on Ubuntu in the guide below. Also, learn about the common errors that can occur during installation.

AWS Command Line Interface (CLI) is a powerful tool that allows you to interact with AWS services through a command-line interface. By using the AWS CLI on Ubuntu, you can streamline your operations, automate tasks, and enhance your productivity. With AWS CLI, you can bid farewell to manual navigation through the AWS Management Console and embrace the power of command-line interactions. This comprehensive guide will walk you through the process of installing and configuring the AWS CLI on Ubuntu, enabling you to harness the full potential of AWS for your projects. In this guide, you will also learn about common errors that can occur during the installation.

How to Install AWS CLI on Ubuntu

To install AWS CLI on Ubuntu, ensure you have a supported version of Ubuntu installed and both Python and Pip installed on your system. Once these requirements are met, you can proceed with the installation process. Follow this step-by-step guide:

  1. Open a Terminal window.
opening terminal 27
  1. Enter the following command to check your Ubuntu version:
<strong>lsb_release -a</strong>
  1. This command will display your Ubuntu version.
checking ubuntu version
  1. Update the package list by opening a Terminal and running the command:
<strong>sudo apt update</strong>
  1. This command will refresh the package list to ensure you have the latest versions available.
updating system package list 12
  1. Install Python by executing the following command:
<strong>sudo apt install python3</strong>
  1. This command will install Python, a programming language required for AWS CLI.
installing python on ubuntu
  1. Verify the Python installation by checking the version:
<strong>python3 --version</strong>
  1. This command will display the installed Python version.
checking python version
  1. Install Pip, the package installer for Python, using the command:
<strong>sudo apt install python3-pip</strong>
  1. This command will install Pip, which is necessary for managing Python packages.
installing pip on ubuntu
  1. Verify the Pip installation by checking the version:
<strong>pip3 --version</strong>
  1. This command will display the installed Pip version.
checking pip version
  1. Now you can install AWS CLI using Python and Pip, by running the following command to install AWS CLI using Pip:
<strong>pip3 install awscli --upgrade --user</strong>
  1. This command will install AWS CLI on your Ubuntu system, specifically for the current user.
installing awscli on ubuntu
  1. To ensure that AWS CLI is installed correctly, you can check the version by running the following command in the Terminal:
<strong>aws --version</strong>
  1. The command will display the installed AWS CLI version.
viewing installed version of awscli

How to Configure AWS CLI

After successfully installing AWS Command Line Interface (CLI), the next crucial step is to configure it with your AWS access credentials. Configuring AWS CLI allows you to authenticate and interact with your AWS resources seamlessly. To authenticate with AWS CLI, you’ll need an AWS access key and secret access key. If you don’t have these credentials, follow these steps to generate them:

  1. Go to the AWS Management Console. Select Identity and Access Management (IAM) service, provide your registered ID, and then cleck on Next button. You can also create a new account by providing the credentials. 
loging to aws management console
  1. Entering credentials to sign in.
entering credentials to signin
  1. Now open the security credentials by clicking on the username on the top right corner of AWS Management Console.
opening security credentials
  1. Navigate to the Users section in the IAM dashboard.
opening users tab from IAM dashboard
  1.  Select the user to which you want to create the access key.
choosing user to create access key
  1. Go to the security credentials tab of the user.
choosing security credentials tab of user
  1. Under the Security credentials tab, click Create access key.
navigating to access key section
  1. Now choose the use case for which you want to create the access key. In this case, I am selecting the command line interface.
choosing usecase for access key
  1. Now accept terms and conditions and click on the Next button to proceed further.
accepting terms and conditions
  1. Click on Create Access Key button to generate access key.
generating access key for awscli
  1. Take note of the generated access key ID and secret access key.
save or download access key
  1. Configuring AWS CLI with Access Keys: Configure AWS CLI by running the following command in the Terminal:
<strong>aws configure</strong>
  1. You will be prompted to enter your AWS access key ID, secret access key, default region, and output format. Provide the required information accordingly.
configuring aws

4 Common Errors When Installing AWS CLI on Ubuntu

During the installation of AWS CLI on Ubuntu, you might come across a few common errors. By being aware of these common errors and their solutions, you can overcome installation hurdles and successfully install AWS CLI on Ubuntu, enabling you to leverage its powerful features for efficient AWS resource management. Let’s explore four common errors and their solutions:

  • 🧰 “Command not found” error: This error typically occurs when the AWS CLI executable is not found in the system’s PATH variable. It means that the installation did not complete successfully or the installation directory is not added to the PATH. To resolve this error, ensure that the installation was successful and the AWS CLI executable path is added to the PATH environment variable. You can add it manually to the PATH or reinstall AWS CLI following the installation instructions.
  • 🔒 “Permission denied” error: The “Permission denied” error occurs when the user executing the installation command does not have sufficient permissions to install packages or modify system files. To resolve this error, run the installation command with sudo to elevate your privileges. For example: sudo pip3 install awscli –upgrade –user. Make sure you have administrative rights or consult with your system administrator for the necessary permissions.
  • 🌐 “Could not connect to the Internet” error: If your Ubuntu system is unable to connect to the Internet, the AWS CLI installation process will fail as it requires network connectivity to download and install dependencies. Ensure that your Ubuntu system has a working internet connection. Check your network settings, proxy configurations, and firewall settings. If you are behind a proxy, configure the proxy settings for the installation process by setting the appropriate environment variables.
  • 📦 “Version conflict” error: If you have an older version of AWS CLI already installed on your Ubuntu system, it can cause version conflicts when trying to install a newer version. To resolve this error, uninstall the existing AWS CLI version before proceeding with the installation of the newer version. Use the appropriate package manager or pip command to remove the old version and then install the latest version of AWS CLI.

In a Nutshell

I hope this guide has provided you with a clear understanding of how to install AWS CLI on Ubuntu. By following the step-by-step installation instructions, you can harness the power of AWS CLI to efficiently manage your AWS resources. Remember to be mindful of the common errors that may occur during installation and refer back to the article for their solutions.

To further expand your knowledge and explore advanced techniques, consider diving into the following articles: Advanced AWS CLI Techniques, Leveraging AWS CLI for Serverless Application Deployment, and AWS CLI Best Practices. By exploring these resources, you’ll gain valuable insights into advanced AWS CLI usage, techniques, and best practices. Unlock the full potential of AWS CLI, optimize your workflows, and take your AWS management skills to new heights.

Frequently Asked Questions

Can AWS CLI be used offline or in restricted network environments?

Yes, AWS CLI can be used offline or in restricted network environments. While some AWS CLI commands require network connectivity to interact with AWS services, many commands can be executed offline or in environments with limited internet access. AWS CLI supports offline functionality by caching information locally, allowing you to perform various tasks without a constant internet connection. This makes AWS CLI a versatile tool that can adapt to different network environments, providing flexibility and convenience in managing AWS resources.

Is it possible to use AWS CLI with multiple AWS accounts?

Yes, AWS CLI allows you to configure and switch between multiple AWS accounts using profiles. Profiles enable you to store and manage different sets of AWS access keys and settings for various accounts within the AWS CLI configuration. By using the aws configure command, you can create and manage profiles, associating each profile with a specific AWS account. This allows you to seamlessly switch between different accounts and access their respective AWS resources using AWS CLI, providing a convenient way to manage multiple AWS environments from a single command-line interface.

Are there any graphical user interfaces (GUIs) available for AWS CLI?

While AWS CLI primarily operates through the command line, there are third-party tools and IDE integrations available that provide graphical interfaces for AWS CLI commands. These GUIs aim to simplify the execution of AWS CLI commands by providing a visual representation of the commands and their parameters. They often offer features such as command autocompletion, syntax highlighting, and intuitive navigation, making it easier to interact with AWS services. Popular examples of AWS CLI GUIs include AWS Toolkit for Visual Studio Code, AWS Management Console, and various cloud management platforms that offer graphical interfaces for AWS CLI commands.

Can I use AWS CLI without providing access keys every time?

Yes, you can configure AWS CLI with access keys and other configuration settings using the aws configure command. Once you have configured AWS CLI with your access keys, it will use the specified access keys by default for subsequent commands, eliminating the need to provide them every time. Additionally, AWS CLI allows you to set a default profile, which automatically selects the appropriate access keys and configuration settings based on the chosen profile. This streamlines the usage of AWS CLI, making it more convenient and efficient for managing AWS resources without the hassle of repeatedly entering access keys.

Ojash

Author

Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.

Akshat

Reviewer

Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

21 Easy Steps to Install Metasploit on Kali Linux

Next Post

How to Delete Files on Git [3 Effective Methods]

Leave a Reply

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

Read next