How to Install AWS CLI on ubuntu 16.04/18.04 Linux
This post will guide you how to install AWS CLI on Ubuntu 16.04/18.04 Linux. You can install the AWS Command Line Interface (AWS CLI) and its dependencies on Ubuntu linux by pip tool ( A package manager for Python). Or you can use the the default repositories via apt command to install AWS CLI on Ubuntu 18.04 Linux.
- What is AWS CLI
- Install AWS CLI using the Default Repository
- Install AWS CLI Using pip Tool
- Install AWS CLI Using Snap
What is AWS Command Line Interface?
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts. The AWS CLI introduces a new set of simple file commands for efficient file transfers to and from Amazon S3.
Install AWS CLI using the Default Repository
The AWS CLI Package is available in repository for apt package manager in Ubuntu 18.04 Linux, so You can use the default repository to install the AWS CLI tool on Your Ubuntu Linux. You can use the apt command to install it. Type the following command:
$ sudo apt install awscli
Outptus:
devops@devops-osetc:~$ sudo apt install awscli
[sudo] password for devops:
Sorry, try again.
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
amd64-microcode btrfs-tools gcc-6-base:i386 intel-microcode iucode-tool libboost-random1.58.0 libboost-thread1.58.0 libcapnp-0.5.3
libevent-core-2.0-5 libhardware2 libhybris libhybris-common1 libiscsi2 libmedia1 librpm3 librpmbuild3 librpmio3 librpmsign3
libwebpdemux1 libwxgtk-media3.0-0v5 libwxgtk-media3.0-dev libwxgtk3.0-0v5 libwxgtk3.0-dev libxen-4.6 linux-generic
linux-generic-hwe-16.04 linux-headers-generic linux-headers-generic-hwe-16.04 linux-image-generic linux-image-generic-hwe-16.04
qml-module-qtwebkit snap-confine snapd-login-service thermald xserver-xorg-input-evdev-hwe-16.04
xserver-xorg-input-synaptics-hwe-16.04 xserver-xorg-video-amdgpu-hwe-16.04 xserver-xorg-video-qxl-hwe-16.04
xserver-xorg-video-vesa-hwe-16.04
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
docutils-common python3-botocore python3-colorama python3-dateutil python3-docutils python3-jmespath python3-pygments python3-roman
python3-rsa python3-s3transfer
Suggested packages:
docutils-doc fonts-linuxlibertine | ttf-linux-libertine texlive-lang-french texlive-latex-base texlive-latex-recommended
ttf-bitstream-vera
The following NEW packages will be installed:
awscli docutils-common python3-botocore python3-colorama python3-dateutil python3-docutils python3-jmespath python3-pygments
python3-roman python3-rsa python3-s3transfer
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,503 kB of archives.
After this operation, 37.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 python3-dateutil all 2.6.1-1 [52.3 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/main amd64 docutils-common all 0.14+dfsg-3 [156 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic/main amd64 python3-roman all 2.0.0-3 [8,624 B]
Get:4 http://mirrors.aliyun.com/ubuntu bionic/main amd64 python3-docutils all 0.14+dfsg-3 [363 kB]
Get:5 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 python3-jmespath all 0.9.3-1ubuntu1 [18.7 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 python3-botocore all 1.8.48+repack-1 [1,764 kB]
Get:7 http://mirrors.aliyun.com/ubuntu bionic/main amd64 python3-colorama all 0.3.7-1 [14.9 kB]
Get:8 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 python3-rsa all 3.4.2-1 [29.0 kB]
Get:9 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 python3-s3transfer all 0.1.13-1 [39.8 kB]
Get:10 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 awscli all 1.14.44-1ubuntu1 [482 kB]
Get:11 http://mirrors.aliyun.com/ubuntu bionic/main amd64 python3-pygments all 2.2.0+dfsg-1 [574 kB]
Fetched 3,503 kB in 26s (132 kB/s)
Selecting previously unselected package python3-dateutil.
(Reading database ... 199574 files and directories currently installed.)
Preparing to unpack .../00-python3-dateutil_2.6.1-1_all.deb ...
Unpacking python3-dateutil (2.6.1-1) ...
Selecting previously unselected package docutils-common.
Preparing to unpack .../01-docutils-common_0.14+dfsg-3_all.deb ...
Unpacking docutils-common (0.14+dfsg-3) ...
Selecting previously unselected package python3-roman.
Preparing to unpack .../02-python3-roman_2.0.0-3_all.deb ...
Unpacking python3-roman (2.0.0-3) ...
Selecting previously unselected package python3-docutils.
Preparing to unpack .../03-python3-docutils_0.14+dfsg-3_all.deb ...
Unpacking python3-docutils (0.14+dfsg-3) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../04-python3-jmespath_0.9.3-1ubuntu1_all.deb ...
Unpacking python3-jmespath (0.9.3-1ubuntu1) ...
Selecting previously unselected package python3-botocore.
Preparing to unpack .../05-python3-botocore_1.8.48+repack-1_all.deb ...
Unpacking python3-botocore (1.8.48+repack-1) ...
Selecting previously unselected package python3-colorama.
Preparing to unpack .../06-python3-colorama_0.3.7-1_all.deb ...
Unpacking python3-colorama (0.3.7-1) ...
Selecting previously unselected package python3-rsa.
Preparing to unpack .../07-python3-rsa_3.4.2-1_all.deb ...
Unpacking python3-rsa (3.4.2-1) ...
Selecting previously unselected package python3-s3transfer.
Preparing to unpack .../08-python3-s3transfer_0.1.13-1_all.deb ...
Unpacking python3-s3transfer (0.1.13-1) ...
Selecting previously unselected package awscli.
Preparing to unpack .../09-awscli_1.14.44-1ubuntu1_all.deb ...
Unpacking awscli (1.14.44-1ubuntu1) ...
Selecting previously unselected package python3-pygments.
Preparing to unpack .../10-python3-pygments_2.2.0+dfsg-1_all.deb ...
Unpacking python3-pygments (2.2.0+dfsg-1) ...
Setting up python3-roman (2.0.0-3) ...
Setting up docutils-common (0.14+dfsg-3) ...
Setting up python3-colorama (0.3.7-1) ...
Processing triggers for sgml-base (1.29) ...
Setting up python3-rsa (3.4.2-1) ...
Setting up python3-docutils (0.14+dfsg-3) ...
update-alternatives: using /usr/share/docutils/scripts/python3/rst-buildhtml to provide /usr/bin/rst-buildhtml (rst-buildhtml) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2html to provide /usr/bin/rst2html (rst2html) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2html4 to provide /usr/bin/rst2html4 (rst2html4) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2html5 to provide /usr/bin/rst2html5 (rst2html5) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2latex to provide /usr/bin/rst2latex (rst2latex) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2man to provide /usr/bin/rst2man (rst2man) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2odt to provide /usr/bin/rst2odt (rst2odt) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2odt_prepstyles to provide /usr/bin/rst2odt_prepstyles (rst2odt_prepstyles) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2pseudoxml to provide /usr/bin/rst2pseudoxml (rst2pseudoxml) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2s5 to provide /usr/bin/rst2s5 (rst2s5) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2xetex to provide /usr/bin/rst2xetex (rst2xetex) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rst2xml to provide /usr/bin/rst2xml (rst2xml) in auto mode
update-alternatives: using /usr/share/docutils/scripts/python3/rstpep2html to provide /usr/bin/rstpep2html (rstpep2html) in auto mode
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Setting up python3-jmespath (0.9.3-1ubuntu1) ...
Setting up python3-dateutil (2.6.1-1) ...
Setting up python3-pygments (2.2.0+dfsg-1) ...
Setting up python3-botocore (1.8.48+repack-1) ...
Setting up python3-s3transfer (0.1.13-1) ...
Setting up awscli (1.14.44-1ubuntu1) ...
Check if the AWS CLI tool is installed properly, type the following command:
$ aws --version
Outputs:
devops@devops-osetc:~$ aws --version
aws-cli/1.14.44 Python/3.6.7 Linux/4.15.0-43-generic botocore/1.8.48
You can also use the configure option for aws command to configure the AWS CLI. Type:
$ aws configure
Install AWS CLI Using pip Tool
You can use the pip tool to install the AWS CLI tool on Ubuntu Linux. Firstly, you need to check if you already installed the pip tool in your Ubuntu Linux, run the pip –version to if your version of Ubuntu Linux already includes python and pip.
$ pip --version
Outputs:
devops@devops-osetc:~$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
If you do not already have pip installed, just type the following apt command to install it, type:
$ sudo apt install python-pip
After installed both python and pip packages, you can start to install the AWS CLI with pip, type the following command:
$ pip install awscli --upgrade --user
Outputs:
devops@devops-osetc:~$ pip install awscli --upgrade --user
Collecting awscli
Downloading https://files.pythonhosted.org/packages/25/f2/ae339ba36dc8774b8fb2b7da1b7351ccdedc7af4b2458221e7ac865b4d2d/awscli-1.16.96-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 196kB/s
Collecting botocore==1.12.86 (from awscli)
Downloading https://files.pythonhosted.org/packages/d7/af/fd9c0f1f0fdc03d3367a56f35093f8b1020ba1a97ead9fa580156895944b/botocore-1.12.86-py2.py3-none-any.whl (5.2MB)
100% |████████████████████████████████| 5.3MB 66kB/s
Collecting docutils>=0.10 (from awscli)
Downloading https://files.pythonhosted.org/packages/50/09/c53398e0005b11f7ffb27b7aa720c617aba53be4fb4f4f3f06b9b5c60f28/docutils-0.14-py2-none-any.whl (543kB)
100% |████████████████████████████████| 552kB 330kB/s
Collecting PyYAML<=3.13,>=3.10 (from awscli)
Downloading https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)
100% |████████████████████████████████| 276kB 247kB/s
Collecting rsa<=3.5.0,>=3.1.2 (from awscli)
Downloading https://files.pythonhosted.org/packages/e1/ae/baedc9cb175552e95f3395c43055a6a5e125ae4d48a1d7a924baca83e92e/rsa-3.4.2-py2.py3-none-any.whl (46kB)
100% |████████████████████████████████| 51kB 2.3MB/s
Collecting colorama<=0.3.9,>=0.2.5 (from awscli)
Downloading https://files.pythonhosted.org/packages/db/c8/7dcf9dbcb22429512708fe3a547f8b6101c0d02137acbd892505aee57adf/colorama-0.3.9-py2.py3-none-any.whl
Collecting s3transfer<0.2.0,>=0.1.12 (from awscli)
Downloading https://files.pythonhosted.org/packages/d7/14/2a0004d487464d120c9fb85313a75cd3d71a7506955be458eebfe19a6b1d/s3transfer-0.1.13-py2.py3-none-any.whl (59kB)
100% |████████████████████████████████| 61kB 2.6MB/s
Collecting jmespath<1.0.0,>=0.7.1 (from botocore==1.12.86->awscli)
Downloading https://files.pythonhosted.org/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl
Collecting python-dateutil<3.0.0,>=2.1; python_version >= "2.7" (from botocore==1.12.86->awscli)
Downloading https://files.pythonhosted.org/packages/74/68/d87d9b36af36f44254a8d512cbfc48369103a3b9e474be9bdfe536abfc45/python_dateutil-2.7.5-py2.py3-none-any.whl (225kB)
100% |████████████████████████████████| 235kB 310kB/s
Collecting urllib3<1.25,>=1.20; python_version == "2.7" (from botocore==1.12.86->awscli)
Downloading https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl (118kB)
100% |████████████████████████████████| 122kB 462kB/s
Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)
Downloading https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl (73kB)
100% |████████████████████████████████| 81kB 424kB/s
Collecting futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" (from s3transfer<0.2.0,>=0.1.12->awscli)
Downloading https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore==1.12.86->awscli)
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Building wheels for collected packages: PyYAML
Running setup.py bdist_wheel for PyYAML ... done
Stored in directory: /home/devops/.cache/pip/wheels/ad/da/0c/74eb680767247273e2cf2723482cb9c924fe70af57c334513f
Successfully built PyYAML
Installing collected packages: jmespath, docutils, six, python-dateutil, urllib3, botocore, PyYAML, pyasn1, rsa, colorama, futures, s3transfer, awscli
Successfully installed PyYAML-3.13 awscli-1.16.96 botocore-1.12.86 colorama-0.3.9 docutils-0.14 futures-3.2.0 jmespath-0.9.3 pyasn1-0.4.5 python-dateutil-2.7.5 rsa-3.4.2 s3transfer-0.1.13 six-1.12.0 urllib3-1.24.1
Note: when you use the –user option, the pip will install the AWS CLI to ~/.local/bin.
You can use the following command to verify that the AWS CLI installed correctly, type:
$ aws --version
Outputs:
devops@devops-osetc:~$ which aws /home/devops/.local/bin/aws devops@devops-osetc:~$ /home/devops/.local/bin/aws --version aws-cli/1.16.96 Python/2.7.15rc1 Linux/4.15.0-43-generic botocore/1.12.86
Install AWS CLI Using Snap
You can also use the snaps command to isntall AWS CLI on Ubuntu 18.04 Linux, type:
$ sudo snap install aws-cli --classic
You can check for the AWS CLI version to confirm the installation, type:
$ aws --version
Outputs:
devops@devops-osetc:~$ aws --version aws-cli/1.14.57 Python/3.5.2 Linux/4.15.0-10-generic botocore/1.9.10
Done!