Running S3cmd commands

 

Overview

S3cmd commands let you manage your DreamObjects data — creating and listing buckets, and uploading, downloading, and deleting objects. This article assumes you've already installed S3cmd:

What if I'm using a custom version of Python?

The commands below work with the server version of Python. However, you may have installed a custom version of Python using the following article:

If so, you may see the following error when running the commands below.

ImportError trying to import dateutil.parser.
Please install the python dateutil module:
$ sudo apt-get install python-dateutil
  or
$ sudo yum install python-dateutil
  or
$ pip install python-dateutil
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

If so, you must create a virtual environment to install the python-dateutil package. You will then be able to use the commands below without error.

Make sure to log out of your SSH session and back in to ensure the new settings are active.

Creating

How do I make a bucket?

[server]$ s3cmd mb s3://my-new-bucket
Bucket 's3://my-new-bucket/' created

Listing

How do I list all buckets?

[server]$ s3cmd ls
2024-03-29 16:28  s3://my-bucket

How do I list the contents of a bucket?

[server]$ s3cmd ls s3://my-bucket
DIR s3://my-bucket/backups/
2024-03-29 18:09 11 s3://my-bucket/file1.txt

How do I list the size of a bucket?

[server]$ s3cmd du -H s3://my-bucket
40G      s3://my-bucket

Uploading

How do I upload a file into a bucket?

[server]$ s3cmd put testfile.txt s3://my-bucket
file.txt -> s3://my-bucket/file.txt  [1 of 1]
127 of 127   100% in    0s  1522.87 B/s  done

Downloading

How do I download a file from a bucket?

[server]$ s3cmd get s3://my-bucket/file.txt
s3://my-bucket/file.txt -> ./file.txt  [1 of 1]
127 of 127   100% in    0s     3.46 kB/s  done

Deleting

How do I delete a file in a bucket?

[server]$ s3cmd del s3://my-bucket/file.txt
File s3://my-bucket/file.txt deleted

Deleting all Objects in a bucket

This will remove all Objects and empty the bucket.

[server]$ s3cmd del --recursive s3://my-bucket --force

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?