Linux command
s3cmd 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Configure s3cmd
s3cmd --configure
List all buckets
s3cmd ls
List contents of a bucket
s3cmd ls s3://[bucket_name]
Create a bucket
s3cmd mb s3://[bucket_name]
Upload a file
s3cmd put [file] s3://[bucket_name]/
Download a file
s3cmd get s3://[bucket_name]/[file]
Sync local directory to S3
s3cmd sync [local_dir]/ s3://[bucket_name]/[path]/
Delete a file
s3cmd del s3://[bucket_name]/[file]
Delete a bucket
s3cmd rb s3://[bucket_name]
说明
s3cmd is a command-line tool for managing Amazon S3 and S3-compatible storage services. It provides a familiar interface for uploading, downloading, and managing files in cloud object storage. Configuration is stored in ~/.s3cfg and includes access keys, encryption settings, and default options. Run --configure for interactive setup. The sync command is particularly powerful for backups, mirroring directories to S3 while only transferring changed files. With --delete-removed, it creates exact mirrors. S3cmd supports server-side encryption, multipart uploads for large files, and can work with S3-compatible services like MinIO, DigitalOcean Spaces, and Wasabi.
参数
- ls _s3://bucket_
- List buckets or objects
- mb _s3://bucket_
- Make bucket
- rb _s3://bucket_
- Remove bucket
- put _file_ _s3://bucket/path_
- Upload file
- get _s3://bucket/path_ _local_
- Download file
- del, rm _s3://bucket/path_
- Delete object
- sync _source_ _dest_
- Sync directories (local to S3 or S3 to local)
- cp _src_ _dst_
- Copy object
- mv _src_ _dst_
- Move object
- info _s3://bucket/object_
- Get info on bucket or object
- du _s3://bucket_
- Disk usage
- la
- List all objects in all buckets
- setacl _s3://bucket/object_
- Modify access control list
- signurl _s3://bucket/object_ _expiry_
- Generate time-limited signed URL
- restore _s3://bucket/object_
- Restore file from Glacier storage
- --configure
- Interactive configuration
- --recursive, -r
- Recursive operation
- --delete-removed
- Delete files not in source during sync
- --dry-run, -n
- Show what would be done
- --acl-public
- Make uploaded files public
- --acl-private
- Make uploaded files private
- --exclude _pattern_
- Exclude files matching pattern
- --include _pattern_
- Include files matching pattern
- --storage-class _CLASS_
- Set storage class (STANDARD, GLACIER, DEEP_ARCHIVE, etc.)
FAQ
What is the s3cmd command used for?
s3cmd is a command-line tool for managing Amazon S3 and S3-compatible storage services. It provides a familiar interface for uploading, downloading, and managing files in cloud object storage. Configuration is stored in ~/.s3cfg and includes access keys, encryption settings, and default options. Run --configure for interactive setup. The sync command is particularly powerful for backups, mirroring directories to S3 while only transferring changed files. With --delete-removed, it creates exact mirrors. S3cmd supports server-side encryption, multipart uploads for large files, and can work with S3-compatible services like MinIO, DigitalOcean Spaces, and Wasabi.
How do I run a basic s3cmd example?
Run `s3cmd --configure` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does ls _s3://bucket_ do in s3cmd?
List buckets or objects