Programster's Blog

Tutorials focusing on Linux, programming, and open-source

AWS CLI S3 Cheatsheet

It's much faster to interface with S3 files through the CLI than it is to use the web browser. Here is a cheatsheet of useful S3 based CLI commands. In order to use these commands, you will need to have configured your AWS settings for authorization.

Remove All Files In A Bucket

aws s3 rm --recursive s3://my-bucket

One cannot use the * character as a wildcard. S3 considers this a valid character for a filename. Hence the use of the --recursive flag.

Copy A Bucket

aws s3 cp --recursive \
  s3://my-bucket \

One can use this to copy files between two different accounts, as long as one of the account's buckets is publicly accessible! The files go direct from server to server (e.g. not through you) so this is super fast!

Move A Bucket's Contents

Same as before but with "mv" instead of "cp"

Upload To Bucket

aws s3 cp \
  /path/to/local/file.txt \

Download File From Bucket

aws s3 cp \
  s3://my-bucket/sub-folder/file.txt \
Last updated: 21st June 2021
First published: 24th March 2020