The AWS CLI is a tool for managing the AWS services from the command-line.
The easiest way to install the AWS CLI on Ubuntu is to get it from the official repository but the version you will get will be much older than the latest one.
In this note i will show how to install the latest version or any specific version of AWS CLI on Linux.
Cool Tip: List Amazon S3 buckets and objects using AWS CLI! Read more →
Install AWS CLI
The easiest way to install the AWC CLI on Ubuntu is to install it from the official repository:
$ sudo apt update $ sudo apt install awscli
The disadvantage of this method of installation is that you will get the version of AWS CLI that will be much older than the latest one.
Install the latest version of the AWS CLI v2:
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" $ unzip awscliv2.zip $ sudo ./aws/install
To install a specific version of the AWS CLI v2, append a hyphen and the version number to the filename, for example:
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.0.52.zip" -o "awscliv2.zip" $ unzip awscliv2.zip $ sudo ./aws/install
The list of the released versions of AWS CLI can be found here.
To verify that the AWS CLI has installed correctly, run:
$ aws --version
Install AWS CLI without Sudo
To install AWS CLI without sudo
you should specify the installation directories that you have write permissions to, for example:
$ mkdir -p ~/local/bin $ ./aws/install -i ~/local/aws-cli -b ~/local/bin
Add the AWS CLI installation directory to the user’s $PATH
variable to be able to execute the aws
command without specifying the full path:
$ export PATH=$PATH:$HOME/local/bin
To make this change permanent, add the PATH=$PATH:$HOME/local/bin
line to the ~/.profile
file:
$ nano ~/.profile $ tail -n1 ~/.profile PATH=$PATH:$HOME/local/bin
To verify that the AWS CLI has installed correctly, run:
$ aws --version
Uninstall AWS CLI
Locate the symlink and install paths:
$ which aws /usr/local/bin/aws $ ls -l /usr/local/bin/aws lrwxrwxrwx 1 root root /usr/local/bin/aws -> /usr/local/aws-cli/v2/current/bin/aws
Delete the symlinks and the install directory:
$ sudo rm /usr/local/bin/aws $ sudo rm /usr/local/bin/aws_completer $ sudo rm -rf /usr/local/aws-cli
If the AWS CLI was installed on Ubuntu using the apt
or apt-get
commands, to uninstall it, simply run:
$ sudo apt auto-remove awscli