LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

s3cmd

Command-line tool for Amazon S3 management

TLDR

Configure s3cmd (interactive setup)
$ s3cmd --configure
copy
List all buckets
$ s3cmd ls
copy
List contents of a bucket
$ s3cmd ls s3://[bucket_name]
copy
Create a bucket
$ s3cmd mb s3://[bucket_name]
copy
Upload a file
$ s3cmd put [file] s3://[bucket_name]/
copy
Download a file
$ s3cmd get s3://[bucket_name]/[file]
copy
Sync local directory to S3
$ s3cmd sync [local_dir]/ s3://[bucket_name]/[path]/
copy
Delete a file
$ s3cmd del s3://[bucket_name]/[file]
copy
Delete a bucket (must be empty)
$ s3cmd rb s3://[bucket_name]
copy

SYNOPSIS

s3cmd [options] command [parameters]

DESCRIPTION

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.

PARAMETERS

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.)
--server-side-encryption
Use S3-managed server-side encryption
--skip-existing
Skip files that already exist at destination
--verbose, -v
Enable verbose output
--limit-rate RATE
Throttle upload/download speed
--config FILE
Use specified config file instead of ~/.s3cfg

CAVEATS

AWS credentials in ~/.s3cfg should have restricted permissions (600). Never commit credentials to version control.Sync operations compare by size and modification time by default. Use --check-md5 for checksum verification at the cost of speed.Large file uploads automatically use multipart upload. For very large files, increase --multipart-chunk-size-mb.Bucket names must be globally unique across all AWS accounts and follow DNS naming conventions.

SEE ALSO

aws(1), rclone(1), gsutil(1), mc(1)

Copied to clipboard
Kai