Install aws cli in Ubuntu

(Last Updated On: July 5, 2019)

How to install aws cli in ubuntu

 

Amazon Web Services is the market leader in cloud computing at present. It provides a variety of services with flexible price module. This flexibility attracts big companies as well as small business minds to use these services. AWS provides a graphical console which is browser-based, but it also provides a command line interface for those who know how to use it.

 

Why do we need to install aws cli?

The AWS CLI (Command Line Interface)  is a unique tool for managing your AWS services. You will need to download and configure this tool, and you can control almost all of the AWS services from the command line if you install aws cli. You can also automate these services through scripts.

Although you can use all of the services through AWS Management Console by signing in with your account, there are other ways like APIs and aws cli that you can use to manage almost all of the important services. Amazon Web Services provide us the option of using aws cli with just a minimal installation and configuration process. You only need some information if you want to install aws cli on a Ubuntu system or any other Linux system.

Things to be noted before you proceed to install aws cli on in your Ubuntu server:

  • AWS Access Key ID
  • AWS Secret Access Key
  • Default region name
  • Default output format

I have also given some examples at the end of this installation part that how you can upload or download an object on the s3 bucket using aws cli.

 

[email protected]:~$ sudo apt update -y
[email protected]:~$ sudo su
[email protected]:~# aws --version
The program 'aws' is currently not installed. You can install it by typing:
apt install awscli
[email protected]:~# apt install awscli  -y

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  docutils-common libjbig0 libjpeg-turbo8 libjpeg8 liblcms2-2 libpaper-utils libpaper1 libtiff5 libwebp5 libwebpmux1 python3-botocore python3-colorama
  python3-dateutil python3-docutils python3-jmespath python3-pil python3-pyasn1 python3-pygments python3-roman python3-rsa python3-s3transfer
Suggested packages:
  liblcms2-utils texlive-latex-recommended texlive-latex-base texlive-lang-french fonts-linuxlibertine | ttf-linux-libertine docutils-doc python-pil-doc
  python3-pil-dbg doc-base ttf-bitstream-vera
The following NEW packages will be installed:
  awscli docutils-common libjbig0 libjpeg-turbo8 libjpeg8 liblcms2-2 libpaper-utils libpaper1 libtiff5 libwebp5 libwebpmux1 python3-botocore python3-colorama
  python3-dateutil python3-docutils python3-jmespath python3-pil python3-pyasn1 python3-pygments python3-roman python3-rsa python3-s3transfer
0 upgraded, 22 newly installed, 0 to remove and 19 not upgraded.
Need to get 3,576 kB of archives.
After this operation, 29.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libjpeg-turbo8 amd64 1.4.2-0ubuntu3.1 [111 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libjbig0 amd64 2.1-3.1 [26.6 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python3-dateutil all 2.4.2-1 [39.1 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 python3-roman all 2.0.0-2 [8,140 B]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 docutils-common all 0.12+dfsg-1 [141 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 python3-docutils all 0.12+dfsg-1 [346 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python3-jmespath all 0.9.0-2 [16.6 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python3-botocore all 1.4.70-1~16.04.0 [1,054 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python3-colorama all 0.3.7-1 [14.9 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 python3-pyasn1 all 0.1.9-1 [28.1 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python3-rsa all 3.2.3-1.1 [27.2 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python3-s3transfer all 0.1.9-1~16.04.0 [35.6 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 awscli all 1.11.13-1ubuntu1~16.04.0 [406 kB]
Get:14 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libjpeg8 amd64 8c-2ubuntu8 [2,194 B]
Get:15 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblcms2-2 amd64 2.6-3ubuntu2.1 [136 kB]
Get:16 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpaper1 amd64 1.1.24+nmu4ubuntu1 [13.7 kB]
Get:17 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpaper-utils amd64 1.1.24+nmu4ubuntu1 [8,276 B]
Get:18 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtiff5 amd64 4.0.6-1ubuntu0.6 [149 kB]
Get:19 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libwebp5 amd64 0.4.4-1 [165 kB]
Get:20 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libwebpmux1 amd64 0.4.4-1 [14.2 kB]
Get:21 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python3-pil amd64 3.1.2-0ubuntu1.1 [313 kB]
Get:22 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 python3-pygments all 2.1+dfsg-1 [520 kB]
Fetched 3,576 kB in 2min 25s (24.6 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libjpeg-turbo8:amd64.
(Reading database ... 92751 files and directories currently installed.)
Preparing to unpack .../libjpeg-turbo8_1.4.2-0ubuntu3.1_amd64.deb ...
Unpacking libjpeg-turbo8:amd64 (1.4.2-0ubuntu3.1) ...
Selecting previously unselected package libjbig0:amd64.
Preparing to unpack .../libjbig0_2.1-3.1_amd64.deb ...
Unpacking libjbig0:amd64 (2.1-3.1) ...
Selecting previously unselected package python3-dateutil.
Preparing to unpack .../python3-dateutil_2.4.2-1_all.deb ...
Unpacking python3-dateutil (2.4.2-1) ...
Selecting previously unselected package python3-roman.
Preparing to unpack .../python3-roman_2.0.0-2_all.deb ...
Unpacking python3-roman (2.0.0-2) ...
Selecting previously unselected package docutils-common.
Preparing to unpack .../docutils-common_0.12+dfsg-1_all.deb ...
Unpacking docutils-common (0.12+dfsg-1) ...
Selecting previously unselected package python3-docutils.
Preparing to unpack .../python3-docutils_0.12+dfsg-1_all.deb ...
Unpacking python3-docutils (0.12+dfsg-1) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../python3-jmespath_0.9.0-2_all.deb ...
Unpacking python3-jmespath (0.9.0-2) ...
Selecting previously unselected package python3-botocore.
Preparing to unpack .../python3-botocore_1.4.70-1~16.04.0_all.deb ...
Unpacking python3-botocore (1.4.70-1~16.04.0) ...
Selecting previously unselected package python3-colorama.
Preparing to unpack .../python3-colorama_0.3.7-1_all.deb ...
Unpacking python3-colorama (0.3.7-1) ...
Selecting previously unselected package python3-pyasn1.
Preparing to unpack .../python3-pyasn1_0.1.9-1_all.deb ...
Unpacking python3-pyasn1 (0.1.9-1) ...
Selecting previously unselected package python3-rsa.
Preparing to unpack .../python3-rsa_3.2.3-1.1_all.deb ...
Unpacking python3-rsa (3.2.3-1.1) ...
Selecting previously unselected package python3-s3transfer.
Preparing to unpack .../python3-s3transfer_0.1.9-1~16.04.0_all.deb ...
Unpacking python3-s3transfer (0.1.9-1~16.04.0) ...
Selecting previously unselected package awscli.
Preparing to unpack .../awscli_1.11.13-1ubuntu1~16.04.0_all.deb ...
Unpacking awscli (1.11.13-1ubuntu1~16.04.0) ...
Selecting previously unselected package libjpeg8:amd64.
Preparing to unpack .../libjpeg8_8c-2ubuntu8_amd64.deb ...
Unpacking libjpeg8:amd64 (8c-2ubuntu8) ...
Selecting previously unselected package liblcms2-2:amd64.
Preparing to unpack .../liblcms2-2_2.6-3ubuntu2.1_amd64.deb ...
Unpacking liblcms2-2:amd64 (2.6-3ubuntu2.1) ...
Selecting previously unselected package libpaper1:amd64.
Preparing to unpack .../libpaper1_1.1.24+nmu4ubuntu1_amd64.deb ...
Unpacking libpaper1:amd64 (1.1.24+nmu4ubuntu1) ...
Selecting previously unselected package libpaper-utils.
Preparing to unpack .../libpaper-utils_1.1.24+nmu4ubuntu1_amd64.deb ...
Unpacking libpaper-utils (1.1.24+nmu4ubuntu1) ...
Selecting previously unselected package libtiff5:amd64.
Preparing to unpack .../libtiff5_4.0.6-1ubuntu0.6_amd64.deb ...
Unpacking libtiff5:amd64 (4.0.6-1ubuntu0.6) ...
Selecting previously unselected package libwebp5:amd64.
Preparing to unpack .../libwebp5_0.4.4-1_amd64.deb ...
Unpacking libwebp5:amd64 (0.4.4-1) ...
Selecting previously unselected package libwebpmux1:amd64.
Preparing to unpack .../libwebpmux1_0.4.4-1_amd64.deb ...
Unpacking libwebpmux1:amd64 (0.4.4-1) ...
Selecting previously unselected package python3-pil:amd64.
Preparing to unpack .../python3-pil_3.1.2-0ubuntu1.1_amd64.deb ...
Unpacking python3-pil:amd64 (3.1.2-0ubuntu1.1) ...
Selecting previously unselected package python3-pygments.
Preparing to unpack .../python3-pygments_2.1+dfsg-1_all.deb ...
Unpacking python3-pygments (2.1+dfsg-1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for shared-mime-info (1.5-2ubuntu0.2) ...
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...
Setting up libjpeg-turbo8:amd64 (1.4.2-0ubuntu3.1) ...
Setting up libjbig0:amd64 (2.1-3.1) ...
Setting up python3-dateutil (2.4.2-1) ...
Setting up python3-roman (2.0.0-2) ...
Setting up docutils-common (0.12+dfsg-1) ...
Setting up python3-jmespath (0.9.0-2) ...
Setting up python3-colorama (0.3.7-1) ...
Setting up python3-pyasn1 (0.1.9-1) ...
Setting up python3-rsa (3.2.3-1.1) ...
Setting up libjpeg8:amd64 (8c-2ubuntu8) ...
Setting up liblcms2-2:amd64 (2.6-3ubuntu2.1) ...
Setting up libpaper1:amd64 (1.1.24+nmu4ubuntu1) ...

Creating config file /etc/papersize with new version
Setting up libpaper-utils (1.1.24+nmu4ubuntu1) ...
Setting up libtiff5:amd64 (4.0.6-1ubuntu0.6) ...
Setting up libwebp5:amd64 (0.4.4-1) ...
Setting up libwebpmux1:amd64 (0.4.4-1) ...
Setting up python3-pil:amd64 (3.1.2-0ubuntu1.1) ...
Setting up python3-pygments (2.1+dfsg-1) ...
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...
Setting up python3-docutils (0.12+dfsg-1) ...
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/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
Setting up python3-botocore (1.4.70-1~16.04.0) ...
Setting up python3-s3transfer (0.1.9-1~16.04.0) ...
Setting up awscli (1.11.13-1ubuntu1~16.04.0) ...
Install aws-cli on linuxProcessing triggers for libc-bin (2.23-0ubuntu11) ...

Check aws version once again,

[email protected]:~# aws --version 
aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-150-generic botocore/1.4.70

Now run the configure command,

[email protected]:~# aws configure
AWS Access Key ID [None]: BKIAIUURA62UHU7DZN6D
AWS Secret Access Key [None]: u0GvMOHwVMXu2wGeYRVK0NW7IWXq6ge/7DEuqv54
Default region name [None]: us-east-1
Default output format [None]: text

Now you can list the content of that bucket,

[email protected]:~# aws s3 ls s3://s3bucket-name/desired-dir-name/
2019-06-22 03:01:08      75877 db_backup-20190622.sql
2019-06-23 03:01:09      75877 db_backup-20190623.sql
2019-06-24 03:01:09      75877 db_backup-20190624.sql
2019-06-25 03:01:10      75877 db_backup-20190625.sql
2019-06-26 03:01:09      75877 db_backup-20190626.sql

Copy file to an s3 bucket from the local server,

[email protected]:~# aws s3 cp /local-directory/filename s3://s3bucket-name/desired-dir-name/

Download file from s3bucket into a local server,

[email protected]:~# aws s3 cp s3://s3bucket-name/desired-dir-name/filename /local-directory/

Sync a local directory with s3bucket,

[email protected]:~# aws s3 sync /local-directory/ s3://s3bucket-name/desired-dir-name/

 

Conclusion:

With this piece of article, I have tried my best to simplify things about the installation and configuration part of aws cli. By following these steps you can easily install aws cli and use AWS services through the command line.

Now I am expecting your responses. If you like this content or even dislike,  just leave a comment. Your responses will motivate me to do better and deliver better. I will try my best to enrich my skill.

So thank you guys, Have a good day.

Rate this content
Sending
User Review
4.8 (5 votes)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ad Blocker Detected

Ad Blocker Detected, please disable it to help this page in many ways. Thank you so much.

Refresh