Skip to main content

S3cmd

S3cmd is a free command-line tool and client for uploading, retrieving, and managing data in Amazon S3 and other cloud storage services that use the S3 protocol. It is an open-source project available under the GNU Public License v2 (GPLv2) and is free for both commercial and personal use.

Overview

S3cmd provides powerful command-line access to OSS with features including:

  • Comprehensive S3 operations for buckets and objects
  • Synchronization capabilities with local file systems
  • Encryption support for data security
  • Bandwidth limiting for controlled transfers
  • Cross-platform compatibility (Linux, macOS, Windows)

Installation

Linux (Ubuntu/Debian)

sudo apt-get update
sudo apt-get install s3cmd

Linux (CentOS/RHEL)

sudo yum install s3cmd
# or for newer versions
sudo dnf install s3cmd

macOS

# Using Homebrew
brew install s3cmd

# Using pip
pip install s3cmd

Windows

# Using pip
pip install s3cmd

Configuration

Interactive Configuration

s3cmd --configure

Enter the following when prompted:

PromptValue
Access KeyYour OSS Access Key
Secret KeyYour OSS Secret Key
Default Regionus-east-1
S3 Endpoint<CustomerId>.oss.swiftserve.com
DNS-style bucket+hostnameNo
Use HTTPS protocolYes

Manual Configuration

Edit ~/.s3cfg:

[default]
access_key = your-access-key
secret_key = your-secret-key
host_base = <CustomerId>.oss.swiftserve.com
host_bucket = <CustomerId>.oss.swiftserve.com
use_https = True

Basic Operations

Bucket Operations

# List all buckets
s3cmd ls

# Create bucket
s3cmd mb s3://my-new-bucket

# Delete empty bucket
s3cmd rb s3://my-bucket

# Delete bucket with all contents
s3cmd rb s3://my-bucket --recursive

Object Operations

# Upload file
s3cmd put file.txt s3://my-bucket/

# Download file
s3cmd get s3://my-bucket/file.txt

# List objects in bucket
s3cmd ls s3://my-bucket/

# Delete object
s3cmd del s3://my-bucket/file.txt

Synchronization

# Sync local directory to bucket
s3cmd sync ./local-folder s3://my-bucket/remote-folder/

# Sync bucket to local directory
s3cmd sync s3://my-bucket/remote-folder/ ./local-folder/

# Sync with delete (remove files not in source)
s3cmd sync ./local-folder s3://my-bucket/ --delete-removed

For more detailed S3cmd documentation, refer to the official S3cmd documentation.