Linux command
aws-s3 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
List all buckets
aws s3 ls
List objects
aws s3 ls s3://[bucket-name]/
Copy a local file
aws s3 cp [file.txt] s3://[bucket-name]/
Download a file
aws s3 cp s3://[bucket-name]/[file.txt] [./local-file.txt]
Sync a local directory
aws s3 sync [./local-dir] s3://[bucket-name]/[prefix/]
Create a new bucket
aws s3 mb s3://[bucket-name]
Remove an empty bucket
aws s3 rb s3://[bucket-name]
Delete an object
aws s3 rm s3://[bucket-name]/[file.txt]
说明
aws s3 provides high-level commands for managing Amazon S3 buckets and objects. It offers a simplified interface for common S3 operations like copying, syncing, and listing files, abstracting away the complexity of the underlying S3 API. The command uses two types of path arguments: LocalPath (absolute or relative path to local files) and S3Uri (S3 resource path in the form s3://bucket-name/key). Most commands accept a source as the first argument and an optional destination as the second. For low-level S3 API access with full control over request parameters, use aws s3api instead.
参数
- --recursive
- Apply command recursively to all files under a directory or S3 prefix
- --exclude _pattern_
- Exclude files matching the pattern from the operation
- --include _pattern_
- Include files matching the pattern (used with --exclude)
- --dryrun
- Display operations that would be performed without executing them
- --acl _value_
- Set the access control list (private, public-read, etc.)
- --storage-class _value_
- Specify storage class (STANDARD, REDUCED_REDUNDANCY, GLACIER, etc.)
FAQ
What is the aws-s3 command used for?
aws s3 provides high-level commands for managing Amazon S3 buckets and objects. It offers a simplified interface for common S3 operations like copying, syncing, and listing files, abstracting away the complexity of the underlying S3 API. The command uses two types of path arguments: LocalPath (absolute or relative path to local files) and S3Uri (S3 resource path in the form s3://bucket-name/key). Most commands accept a source as the first argument and an optional destination as the second. For low-level S3 API access with full control over request parameters, use aws s3api instead.
How do I run a basic aws-s3 example?
Run `aws s3 ls` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --recursive do in aws-s3?
Apply command recursively to all files under a directory or S3 prefix