LinuxCommandLibrary

s3cmd

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 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
--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

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