Examples of s3cmd 2.x Usage with DigitalOcean Spaces
Last verified 22 Jun 2026
Spaces Object Storage is an S3-compatible service for storing and serving large amounts of data. The built-in Spaces CDN minimizes page load times, improves performance, and reduces bandwidth and infrastructure costs.
s3cmd is a cross-platform command-line tool for managing S3 and S3-compatible object storage.
After you set up s3cmd, you can use it to manage Spaces buckets and objects. If you use an alternate configuration file, add -c ~/path/to/config/file to each command.
For the complete s3cmd command reference, see the s3cmd usage guide or run s3cmd --help.
Create Buckets
Use mb to create one or more buckets:
s3cmd mb s3://<your-space-name> s3://<your-second-space>Use Object Paths
Object storage uses a flat namespace and doesn’t have directories. For example, when you upload an object with the key images/logo.png, Spaces stores one object named images/logo.png. The images/ portion is part of the object key, not a separate directory.
Some graphical tools display shared key prefixes, such as images/, as folders to make objects easier to browse. In s3cmd, you don’t need to create those prefixes first. Include the full object key in the destination path when you upload the file.
List Buckets
Use ls and la to list Spaces buckets and objects.
List All Buckets
List all Spaces buckets available to the configured access key:
s3cmd lsList Objects in Specific Buckets
List the objects in one or more specific Spaces buckets:
s3cmd ls s3://<your-space-name> s3://<your-second-space>List All Objects in All Buckets
List all objects in all Spaces buckets recursively:
s3cmd la --recursiveUpload Files to a Bucket
Use put to copy files from your local machine to a bucket.
Upload a File
Include a trailing slash to preserve the original file name at the destination:
s3cmd put file.txt s3://<your-space-name>/path/If you omit the trailing slash and provide a destination name, s3cmd stores the file with that name.
Upload a File with a New Name
Add the new file name to the end of the destination path:
s3cmd put file.txt s3://<your-space-name>/<your-new-file-name>.txtUpload Multiple Files
Upload multiple local files to the same destination path in a Space:
s3cmd put <file1>.txt <file2>.txt <path/to/file3>.txt s3://<your-space-name>/path/Upload All Files in the Current Directory
Use * with --recursive to upload all files in the current working directory:
s3cmd put * s3://<your-space-name>/path/ --recursiveTo make uploaded files public, add --acl-public:
s3cmd put * s3://<your-space-name>/path/ --acl-public --recursiveTo set metadata during upload, add --add-header:
s3cmd put * s3://<your-space-name>/path/ --add-header=Cache-Control:max-age=86400 --recursiveYou can also combine public access and metadata in one upload command:
s3cmd put * s3://<your-space-name>/path/ --acl-public --add-header=Cache-Control:max-age=86400 --recursiveDownload Files to Your Local Computer
Use get to copy files from a bucket to your local computer.
Download a File
Download a single object from a Space to your current local directory:
s3cmd get s3://<your-space-name>/path/to/file.txtDownload All Files in a Path
To download multiple files, include a trailing slash in the Spaces path and use --recursive:
s3cmd get s3://<your-space-name>/path/ --recursiveDownload a File with a New Name
Add the local file name after the Spaces path:
s3cmd get s3://<your-space-name>/file.txt <your-new-filename>.txtSet Directory Listings on a Space
Directory listings control whether users can browse the contents of a Space from its public endpoint.
s3cmd only prints output when a command changes access levels. For example, when you change an ACL from private to public, s3cmd prints output like s3://<your-space-name>/: ACL set to Public. If the ACL is already public, s3cmd returns to the command prompt without output.
Enable Directory Listings
Make the Space publicly listable from its public endpoint:
s3cmd setacl s3://<your-space-name>/ --acl-publicDisable Directory Listings
Make the Space private and prevent public directory listings:
s3cmd setacl s3://<your-space-name>/ --acl-privateSet Permissions on Files
Use setacl to make files public or private.
Private files are only readable by users with valid credentials. Public files are readable by anyone through an S3-compatible client or HTTPS URL.
s3cmd only prints output when a command changes access levels. For example, when you change an ACL from private to public, s3cmd prints output like s3://<your-space-name>/test.txt: ACL set to Public [1 of 1]. If the ACL is already public, s3cmd returns to the command prompt without output.
Make a File Public
Make a single file publicly readable through its object URL:
s3cmd setacl s3://<your-space-name>/file.txt --acl-publicMake Files Public Recursively
Use --recursive to make all files in a path public:
s3cmd setacl s3://<your-space-name>/path/to/files/ --acl-public --recursiveMake a File Private
Make a single file readable only by users with valid credentials:
s3cmd setacl s3://<your-space-name>/file.txt --acl-privateMake Files Private Recursively
Use --recursive to make all files in a path private:
s3cmd setacl s3://<your-space-name>/path/to/files/ --acl-private --recursiveDelete Buckets and Files
The del and rm commands are equivalent and can be used interchangeably. This permanently deletes the bucket and its objects.
Delete an Empty Bucket
Use rb to delete an empty bucket:
s3cmd rb s3://<your-space-name>To delete a bucket and all of its contents, add --recursive:
s3cmd rb s3://<your-space-name> --recursiveDelete a File
Delete a single file from a Space:
s3cmd rm s3://<your-space-name>/name/of/fileDelete All Files in a Bucket
Use rm or del with --recursive and --force to delete all files in a bucket without deleting the bucket:
s3cmd rm s3://<your-space-name>/ --recursive --forceEncrypt Files
Use -e or --encrypt with put to encrypt a file before uploading it:
s3cmd put file.txt s3://<your-space-name>/path/to/file.txt -eIf you download the encrypted file with s3cmd and the same configuration file, s3cmd uses the configured password to decrypt it automatically. Other users need to decrypt the file with GPG, and then enter the encryption password.
s3cmd supports one encryption password per configuration file, so this option works best for a single user or a group with shared administrative access. To learn more about GPG symmetric encryption, see The GNU Privacy Handbook.