Running S3cmd commands

This article lists several commands you can use to mange your DreamObjects data. This article assumes you've already installed S3cmd:

If you're 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 one of the following articles:

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.

Creating

Making a bucket

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

Listing

Listing all buckets

[server]$ s3cmd ls
2019-02-04 16:28  s3://my-bucket

Listing the contents of a bucket

[server]$ s3cmd ls s3://my-bucket
                    DIR s3://my-bucket/backups/
2019-02-04 18:09 11 s3://my-bucket/file1.txt

Listing the size of a bucket

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

Uploading

Uploading 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

Downloading 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

Deleting a file in a bucket

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

Permissions

Recursively making every object in a bucket public

[server]$ s3cmd setacl s3://my-bucket --acl-public --recursive

Recursively making every object in a bucket private

[server]$ s3cmd setacl s3://my-bucket --acl-private --recursive

Directory Listing

Directory listing controls what data can be seen by visiting the top level of your bucket. If it's set to private, no data is shown. If it's public, the contents of the bucket are listed as shown below.

Disabling Directory Listing in a bucket

[server]$ s3cmd setacl s3://my-bucket --acl-private

If you visit your bucket in a browser, only the following information will display.

Enabling Directory Listing in a bucket

[server]$ s3cmd setacl s3://my-bucket --acl-public

If you visit your bucket in a browser, the contents of the bucket display.

Did this article answer your questions?

Article last updated PST.