AWS S3 ls: List Buckets and Objects

List S3 buckets and objects using aws s3 ls with recursive listing, human-readable sizes, and summary statistics.

S3 Operations

Detailed Explanation

Listing S3 Buckets and Objects

The aws s3 ls command lists your S3 buckets or objects within a bucket. It supports recursive listing, human-readable file sizes, and summary statistics.

List All Buckets

aws s3 ls

Output shows creation date and bucket name:

2024-01-15 10:30:00 my-backup-bucket
2024-02-20 14:22:00 my-website-bucket
2024-03-01 09:00:00 my-data-bucket

List Objects in a Bucket

aws s3 ls s3://my-bucket/

List Objects with a Prefix

aws s3 ls s3://my-bucket/logs/2024/

Recursive Listing with Details

aws s3 ls s3://my-bucket/ --recursive --human-readable --summarize

The combined flags provide:

  • --recursive — list all objects, not just the current "directory"
  • --human-readable — show sizes as KB, MB, GB instead of bytes
  • --summarize — add total object count and total size at the end

Example Output

2024-01-15 10:30:00  45.2 KiB logs/app.log
2024-01-15 10:30:00   1.3 MiB data/export.csv
2024-01-16 08:00:00 256.0 KiB images/logo.png

Total Objects: 3
   Total Size: 1.6 MiB

Combining with --query for Filtering

For more advanced filtering, use the s3api list-objects-v2 command with --query:

aws s3api list-objects-v2 \
  --bucket my-bucket \
  --prefix logs/ \
  --query "Contents[?Size > \`1000000\`].[Key,Size]" \
  --output table

Use Case

Auditing S3 bucket contents, checking storage usage across prefixes, verifying backup completeness, or listing objects before performing bulk operations like sync or delete.

Try It — AWS CLI Command Builder

Open full tool