Amazon S3: Common CLI Commands & Reference

Last updated:

WIP Alert This is a work in progress. Current information is correct but more content will probably be added in the future.

We will use "samplebucket" as an example bucket name.

Download a single file

cpis for copy; . stands for the current directory

$ aws s3 cp s3://samplebucket/somefolder/afile.txt .

Download a specific folder and all subfolders, recursively

Useful for downloading log folders

$ aws s3 cp s3://samplebucket/somefolder/ . --recursive

Delete a folder in a bucket

(along with any data within)

$ aws s3 rm s3://samplebucket/somefolder --recursive

Upload a single file to an S3 bucket

$ aws s3 cp /path/to/localfile s3://samplebucket/somefolder

Upload multiple files at the same time

See my post on linux find examples for more ways to use find

Say, for instance, you have multiple files that you want to upload to the same bucket. If they all have names

$ ls
aa ab ac ad ae
$ find . -name "x*" | xargs -I {} aws s3 cp {} s3://samplebucket/samplefolder

View stats about a bucket (total size, etc)

$ aws s3 ls s3://samplebucket/path/to/directory/ --summarize --human-readable --recursive
  • sample output (some rows ommited)
2015-08-24 23:11:03   40.0 MiB news.en-00098-of-00100
2015-08-24 23:11:04   39.9 MiB news.en-00099-of-00100
Total Objects: 100
Total Size: 3.9 GiB


Dialogue & Discussion