aws-s3-ls
List objects in an Amazon S3 bucket
TLDR
List all buckets
List files and folders in the root of a bucket (s3:// is optional)
List files and folders directly inside a directory
List all files in a bucket
List all files in a path with a given prefix
Display help
SYNOPSIS
aws s3 ls [s3://bucket/prefix] [options]
PARAMETERS
s3://bucket/prefix
Specifies the S3 bucket and optional prefix (directory) to list. If omitted, it lists available S3 buckets.
--recursive
Recursively lists all objects under the specified prefix.
--human-readable
Displays object sizes in human-readable format (e.g., KB, MB, GB).
--summarize
Displays the total number of objects and their combined size.
--page-size
Sets the number of results returned per page.
--dryrun
Shows what would happen without actually executing the command.
--cli-read-timeout
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout.
--cli-connect-timeout
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout.
--profile
Use a specific profile from your credential file.
DESCRIPTION
The `aws s3 ls` command is a versatile tool within the AWS Command Line Interface (CLI) used to list objects and common prefixes (think of them as directories) within Amazon Simple Storage Service (S3) buckets. It allows you to explore the contents of your S3 storage, providing a way to identify files and directories without directly downloading them. The command supports various filtering and formatting options, making it easy to drill down to specific objects based on prefixes, sizes, or modification dates. You can use it to get a simple listing of objects, including their size and last modification date or with specific prefix. The `aws s3 ls` command is an essential tool for managing and exploring S3 buckets from the command line, especially useful for automation and scripting where a graphical interface is not available.
CAVEATS
Requires the AWS CLI to be configured with valid credentials and region. Listing very large buckets without specifying prefixes can be slow.
Be mindful of AWS costs associated with S3 operations.
OUTPUT FORMAT
The output format of the command is typically a list of date, time, size, and object name or PREFIX followed by the prefix name.
COMMON USE CASES
Common uses include verifying file uploads, checking bucket contents, automating backups, and scripting data management tasks.
Example: aws s3 ls s3://my-bucket/my-folder
HISTORY
The `aws s3 ls` command is part of the AWS Command Line Interface (CLI), which was developed by Amazon Web Services to provide a command-line interface for interacting with AWS services. Its purpose is to enable developers and system administrators to manage AWS resources, including S3 buckets and objects, through scripts and automated processes. The `aws s3 ls` command has evolved over time with new features and options to provide more flexibility and control over listing objects in S3.