Using AWS S3 from the terminal with awscli

Use AWS S3 from the terminal with awscli: install the aws CLI, then create, list, copy, sync, and delete buckets plus set bucket ACLs and policies via s3api.

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.

In this guide we will see how to work with s3 from the terminal using awscli – aws command.

Installation

AWS Cli is provided as a python pip package. Install it wth this command:

sudo pip install -U aws-cli

Basic operations

Create bucket:

aws s3 mb s3://prod-ph-atlas-auth-certs --region ap-southeast-1

List content of bucket

aws s3 ls s3://bucket-name

Copy local file to bucket

aws s3 cp ~/tmp/account/account-kafka-client-truststore.jks s3://prod-ph-atlas-auth-certs/truststore/

Delete bucket

# Force if not empty
aws s3 rb s3://bucket-name --force

Sync two buckets

aws s3 sync s3://DOC-EXAMPLE-BUCKET-SOURCE s3://DOC-EXAMPLE-BUCKET-TARGET

Get bucket acl

aws s3api get-bucket-acl --bucket kip-revelapp-data

Put bucket policy

aws s3api put-bucket-policy --bucket kip-revelapp-data --policy file://files/s3-bucket-public-read-policy.json

Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::kip-revelapp-data",
                "arn:aws:s3:::kip-revelapp-data/*"
            ]
        }
    ]
}
Last updated on Jul 01, 2026 11:23 +0300
comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy