{"id":2758,"library":"s3cmd","title":"s3cmd Command Line Tool","description":"s3cmd is a free, feature-rich, command-line tool for managing Amazon S3 and other S3-compatible cloud storage services. Written in Python, it allows users to upload, retrieve, and manage data with simple shell commands. The current version is 2.4.0, and it follows an active maintenance release cadence.","status":"active","version":"2.4.0","language":"en","source_language":"en","source_url":"https://github.com/s3tools/s3cmd","tags":["aws","s3","cli","storage","cloud"],"install":[{"cmd":"pip install s3cmd","lang":"bash","label":"Install s3cmd"}],"dependencies":[],"imports":[{"note":"s3cmd is primarily a command-line utility, not a Python library intended for direct programmatic import. To interact with it from Python, execute the `s3cmd` binary via the `subprocess` module.","wrong":"import s3cmd","symbol":"s3cmd CLI","correct":"import subprocess\nsubprocess.run(['s3cmd', 'version'], check=True)"}],"quickstart":{"code":"import subprocess\n\n# s3cmd requires prior configuration (e.g., via `s3cmd --configure` or AWS environment variables/IAM roles).\n# This example assumes s3cmd is configured to access an S3 bucket.\n\n# Example: List S3 buckets\ntry:\n    # Using check=True will raise CalledProcessError if s3cmd exits with a non-zero status\n    result = subprocess.run(['s3cmd', 'ls'], check=True, capture_output=True, text=True)\n    print(\"S3 Buckets:\\n\", result.stdout)\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error listing buckets: {e.stderr}\")\n    print(\"Ensure s3cmd is correctly configured (e.g., with valid credentials in ~/.s3cfg).\")\nexcept FileNotFoundError:\n    print(\"s3cmd command not found. Ensure it's installed and in your system's PATH.\")\n","lang":"python","description":"Demonstrates how to interact with the s3cmd command-line tool from a Python script using the `subprocess` module to list S3 buckets. Users must ensure s3cmd is installed and configured with appropriate AWS credentials (e.g., via `s3cmd --configure` or environment variables)."},"warnings":[{"fix":"Review your `~/.s3cfg` file and remove or set `signature_v2 = False`. Ensure your AWS region supports SigV4 (most modern regions do). Re-run `s3cmd --configure` to generate a new, compliant configuration if needed.","message":"Since version 2.0.0, AWS Signature Version 4 (SigV4) is the default and preferred signing method. If you have an existing `.s3cfg` configuration that explicitly forces AWS Signature Version 2 (`signature_v2 = True`), operations might fail or behave unexpectedly with newer AWS regions.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Run `s3cmd --configure` to create or update your `~/.s3cfg` file, providing your AWS Access Key, Secret Key, and optionally a default region. Ensure the file has appropriate permissions (e.g., `chmod 600 ~/.s3cfg`).","message":"s3cmd relies heavily on its configuration file, typically located at `~/.s3cfg`. Incorrect or missing configurations (e.g., access keys, secret keys, default region) will lead to authentication failures or unexpected behavior.","severity":"gotcha","affected_versions":"all"},{"fix":"To upload objects without SSE-S3 encryption, use the `--no-encryption` option. For other encryption types (e.g., SSE-C, SSE-KMS), refer to the s3cmd documentation for specific options like `--sse` or `--encrypt`.","message":"Starting with version 2.0.0, Server-Side Encryption (SSE-S3) is enabled by default for new object uploads. If you require unencrypted objects or a different encryption method, you must explicitly specify it.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always double-check your `s3cmd del` or `s3cmd rm` commands before adding `--force`. Consider using the `--dry-run` option first to preview the operations that would be performed without actually executing them.","message":"When deleting objects or buckets, s3cmd often requires the `--force` option. Using `--force` can lead to irreversible data loss if used incorrectly, especially with recursive deletes or bucket removals.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the `--host` and `--host-bucket` options to point to the specific endpoint of your S3-compatible service. For example, `--host=sgp1.digitaloceanspaces.com --host-bucket=%(bucket)s.sgp1.digitaloceanspaces.com` for DigitalOcean Spaces.","message":"Connecting to non-AWS S3-compatible storage services (e.g., MinIO, DigitalOcean Spaces) requires specifying custom host and bucket host parameters, as defaults are for AWS S3.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}