Last update:2025-06-30 17:29:52
This chapter will introduce how to use the s3cmd tool to synchronize local files to object storage.
Choose one of the following commands according to your operating system to execute:
# CentOS/RHEL system
Yum installation: sudo yum install s3cmd
# Debian/Ubuntu system
APT installation: sudo apt-get install s3cmd
Execute the configuration command and fill in the information as prompted:
s3cmd --configure
Configuration Example
Edit the generated ~/.s3cfg file (or enter directly during the configuration process). Refer to the content below:
[default]
access_key = 5f5a1ca5xxxxxxxxxacf61afda42
host_base = s3-cn-east-2.wcsapi.com
host_bucket = %(bucket)s.s3-cn-east-2.wcsapi.com
secret_key = 4f32262xxxxxxxxxxxxcbbc7269a8c9
... (the rest of the default configuration is not posted)
Note:
- A ~/.s3cfg file will be automatically generated in the user directory upon configuration completion
- You need to replace access_key and secret_key with your actual keys
- For more configuration parameter descriptions, use
s3cmd -h
Basic synchronization command:
s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX]
Examples for common scenarios:
1. Use relative path: first cd into E:\videos\ then: s3cmd sync . s3://my-bucket/videos/
2. Use absolute path: s3cmd sync E:\videos\. s3://my-bucket/videos/
# Output detailed operation information
s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX] --debug
s3cmd put localPath s3://my-bucket/keyName
# View the full list of commands
s3cmd -h