Upload files and folder to S3 from Ubuntu 20.04 using AWS CLI 2

Applicable for Ubuntu 20.04 and its derivatives.

Creating a IAM User

To make any API call to AWS, we need a IAM user with appropriate permissions. According to the your purpose, create a IAM user and get the followings

  • Access Key ID
  • Secret Access Key

Install AWS CLI in Local Machine

Install AWS CLI

Install curl if it is not install in your machine. Also, you can use wget the default and preinstalled download manager for Ubuntu.

sudo apt-get install curl
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version

Configure Account

To configure your account

aws configure
aws s3 ls

Upload Files and Folders

If you do not have a S3 bucket create one.

Upload a Single File

To upload a single file we use the following

aws s3 cp local_file_path s3://bucket_name/
aws s3 cp /home/nahid/Documents/data.json s3://test_bucket/

Upload All Files and Folder Recursively

To upload a folder along with all its files and folders, we can do the followings,

aws s3 cp local_folder_path s3://bucket_name/ --recursive
aws s3 cp /home/nahid/Documents/build s3://test_bucket/ --recursive



A lifelong learner. Love to travel, listen to music, and hang out with friends. I believe in simplicity and peace.