Below is the cheat sheet of AWS CLI commands for S3.
If you are new to S3 it’s recommended that you go through this free AWS S3 crash course.
If you want to know how to install AWS CLI, follow steps on this post.
aws s3 help
aws s3api help
aws s3 mb s3://bucket-name
aws s3 rb s3://bucket-name
To remove a non-empty bucket (Extremely careful while running this). This will remove all contents in the bucket including subfolders and data in them.
aws s3 rb s3://bucket-name --force
aws s3 cp mypic.png s3://mybucket/
aws s3 cp myfolder s3://mybucket/myfolder --recursive
(Note: –recursive will copy recursively everything including the subfolders)
aws s3 sync <source> <target> [--options]
More examples of using sync and cp commands in this post.
aws s3 ls
List specific bucket
aws s3 ls s3://mybucket
aws s3api get-bucket-location --bucket <bucket-name>
aws s3api get-bucket-logging --bucket <bucket-name>
ACL (Access Control List)
The following example copies an object into a bucket. It grants read permissions on the object to everyone and full permissions (read, readacl, and writeacl) to the account associated with email@example.com.
aws s3 cp file.txt s3://my-bucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers firstname.lastname@example.org