# aws s3 ls

AWS CLI commands · Updated 16 November 2026

**Short answer:** aws s3 ls lists your buckets; aws s3 ls s3://my-bucket/path/ lists the objects and "folders" (prefixes) under a path. Add --recursive to list every object below it and --human-readable --summarize for sizes and a total.

## What the command does

`aws s3 ls` is a convenience command built on the S3 API, not an API operation itself. Its output is plain text in a fixed format, one line per item:

```
                           PRE logs/
2026-11-15 17:02:44      48213 index.html
2026-11-16 08:10:05    1048576 data/export.csv
```

`PRE` marks a common prefix, which the console shows as a folder. Dates are in your local time zone. Because the format is fixed, `--output json` and `--query` have no useful effect; for structured output use [s3api list-objects-v2](https://cloudconsole.dev/cli/s3api-list-objects-v2).

## Syntax

```
aws s3 ls [s3://bucket[/prefix]] \
  [--recursive] [--human-readable] [--summarize] \
  [--page-size <n>] [--request-payer requester]
```

## Worked examples

**All buckets in the account:**

```
aws s3 ls
```

**One level under a prefix.** The trailing slash matters: without it, `logs` also matches `logs-archive/`:

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

**Everything below a prefix, with sizes and a total:**

```
aws s3 ls s3://my-bucket/logs/2026/11/ --recursive --human-readable --summarize
```

```
2026-11-16 00:05:12   12.4 MiB logs/2026/11/16/app-00.gz
...

Total Objects: 1442
   Total Size: 17.9 GiB
```

**Newest five objects** (sorting the text output):

```
aws s3 ls s3://my-bucket/uploads/ --recursive | sort | tail -n 5
```

**A public bucket, without any AWS credentials:**

```
aws s3 ls s3://some-public-dataset/ --no-sign-request
```

## Counting and sizing a prefix

The `--summarize` footer is the quickest way to answer "how much is in here?" for a prefix of modest size. Pipe the recursive listing through standard tools for other questions, such as how many objects were written on a given day:

```
aws s3 ls s3://my-bucket/uploads/ --recursive | grep -c '^2026-11-16'
```

Remember that each line is a separate object and the listing reflects the moment it ran; objects written while it pages through a big prefix may or may not appear.

## Errors you will meet

| Message | Fix |
|---|---|
| `Unable to locate credentials` | No credentials in this shell. Configure a profile or log in; see [unable to locate credentials](https://cloudconsole.dev/errors/unable-to-locate-credentials). |
| `An error occurred (AccessDenied) when calling the ListObjectsV2 operation` | You need `s3:ListBucket` on the bucket ARN (`arn:aws:s3:::my-bucket`, without `/*`). See [S3 AccessDenied](https://cloudconsole.dev/errors/s3-access-denied). |
| `AccessDenied` calling `ListBuckets` | Plain `aws s3 ls` needs `s3:ListAllMyBuckets`. Name the bucket directly instead. |
| `NoSuchBucket` | Typo or deleted bucket; see [NoSuchBucket](https://cloudconsole.dev/errors/s3-nosuchbucket). |

## Gotchas

- **Big prefixes are slow and cost requests.** A recursive listing of millions of objects makes one LIST request per 1,000 keys. For bucket-wide sizes, use the CloudWatch `BucketSizeBytes` metric or S3 Storage Lens; see [finding the largest buckets](https://cloudconsole.dev/how-to/find-largest-s3-buckets).
- **Only current versions.** Previous versions and delete markers are not shown; use [s3api list-object-versions](https://cloudconsole.dev/cli/s3api-list-object-versions).
- **Empty "folders" appear only if a zero-byte object with a trailing slash exists.** Prefixes are not real directories.
- **Bucket listing is global, objects are regional.** If listing a bucket in another Region fails, add `--region` with the bucket's Region.

## Questions

### How do I get JSON output from aws s3 ls?

You cannot; s3 ls always prints text. Use aws s3api list-objects-v2 --bucket my-bucket --prefix path/ with --query and --output json for structured results.

### How do I use aws s3 ls without credentials?

Add --no-sign-request. It works only for buckets that allow anonymous listing.

### Why does aws s3 ls give access denied when I can read objects?

Listing needs s3:ListBucket on the bucket itself, while reading needs s3:GetObject on objects. Policies often grant one but not the other.

## When this happens away from your desk

Checking whether a file landed in a bucket is a common quick question. CloudConsole, a phone app for AWS, is built to show resources, alarms and costs on a phone.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [aws s3 ls (AWS CLI Command Reference)](https://docs.aws.amazon.com/cli/latest/reference/s3/ls.html)
- [Use high-level (s3) commands with the AWS CLI (User Guide)](https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html)

## Related

- [aws s3 cp](https://cloudconsole.dev/cli/s3-cp)
- [aws s3api list-objects-v2](https://cloudconsole.dev/cli/s3api-list-objects-v2)
- [S3 AccessDenied: Access Denied when calling an S3 operation](https://cloudconsole.dev/errors/s3-access-denied)
- [Unable to locate credentials](https://cloudconsole.dev/errors/unable-to-locate-credentials)
- [How to find S3 bucket size](https://cloudconsole.dev/how-to/find-largest-s3-buckets)
- [aws s3 mb](https://cloudconsole.dev/cli/s3-mb)

---

Source: https://cloudconsole.dev/cli/s3-ls

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
