List of commonly used S3 AWS CLI Commands
Create Bucket
aws s3 mb s3://bucket-name
Remove Bucket
aws s3 rb s3://bucket-name
List Buckets
aws s3 ls
List contents inside the bucket
aws s3 ls s3://bucket-name
List Bucket with a path
aws s3 ls s3://bucket-name/path
Copy file
aws s3 cp file.txt s3://my-bucket/
Synchronize files
aws s3 sync . s3://my-bucket/path
Delete local file
rm ./MyFile1.txt
Attempt sync without --delete option - nothing happens
aws s3 sync . s3://my-bucket/path
Sync with deletion - object is deleted from bucket
aws s3 sync . s3://my-bucket/path --delete
Delete object from bucket
aws s3 rm s3://my-bucket/path/MySubdirectory/MyFile3.txt
Sync with deletion - local file is deleted
aws s3 sync s3://my-bucket/path . --delete
Sync with Infrequent Access storage class
aws s3 sync . s3://my-bucket/path --storage-class STANDARD_IA
Copy MyFile.txt in current directory to s3://my-bucket/path
aws s3 cp MyFile.txt s3://my-bucket/path/
Move all .jpg files in s3://my-bucket/path to ./MyDirectory
aws s3 mv s3://my-bucket/path ./MyDirectory --exclude '*' --include '*.jpg' --recursive
List the contents of my-bucket
aws s3 ls s3://my-bucket
List the contents of path in my-bucket
aws s3 ls s3://my-bucket/path
Delete s3://my-bucket/path/MyFile.txt
aws s3 rm s3://my-bucket/path/MyFile.txt
Delete s3://my-bucket/path and all of its contents
aws s3 rm s3://my-bucket/path --recursive