04. Command Cheatsheet

OpenStack Commands

Authentication

# Source OpenStack credentials
source def-ubcawp-dev-openrc.sh

# Verify authentication
openstack image list

EC2 Credentials

# Create EC2 credentials for S3 access
openstack ec2 credentials create

# List EC2 credentials
openstack ec2 credentials list

# Delete EC2 credentials
openstack ec2 credentials delete <credential-id>

S3 Commands (s3cmd)

Configuration

# Configure s3cmd
s3cmd --configure

# Test configuration
s3cmd ls

Bucket Operations

# Create a bucket
s3cmd mb s3://BUCKET_NAME/

# List all buckets
s3cmd ls

# List contents of a bucket
s3cmd ls s3://BUCKET_NAME/

# Get bucket information
s3cmd info s3://BUCKET_NAME/

# Delete an empty bucket
s3cmd rb s3://BUCKET_NAME/

# Delete a bucket and all its contents
s3cmd rb --recursive s3://BUCKET_NAME/

File Operations

# Upload a file
s3cmd put --guess-mime-type FILE_NAME.dat s3://BUCKET_NAME/FILE_NAME.dat

# Upload a file with custom path
s3cmd put --guess-mime-type local_file.txt s3://BUCKET_NAME/path/to/remote_file.txt

# Upload a directory recursively
s3cmd put --recursive --guess-mime-type local_dir/ s3://BUCKET_NAME/

# Download a file
s3cmd get s3://BUCKET_NAME/FILE_NAME.dat local_file.dat

# Download a directory recursively
s3cmd get --recursive s3://BUCKET_NAME/remote_dir/ local_dir/

# Delete a file
s3cmd rm s3://BUCKET_NAME/FILE_NAME.dat

# Delete multiple files (pattern matching)
s3cmd del s3://BUCKET_NAME/*.tmp

# Delete directory recursively
s3cmd del --recursive s3://BUCKET_NAME/path/to/dir/

Access Control

# Make bucket public (recursive)
s3cmd setacl --acl-public -r s3://BUCKET_NAME/

# Make bucket private
s3cmd setacl --acl-private s3://BUCKET_NAME/

# Set ACL for specific file
s3cmd setacl --acl-public s3://BUCKET_NAME/FILE_NAME.dat

# Get ACL information
s3cmd info s3://BUCKET_NAME/

Synchronization

# Sync local directory to bucket
s3cmd sync local_dir/ s3://BUCKET_NAME/remote_dir/

# Sync bucket to local directory
s3cmd sync s3://BUCKET_NAME/remote_dir/ local_dir/

# Sync with exclusions
s3cmd sync --exclude '*.tmp' --exclude '*.log' local_dir/ s3://BUCKET_NAME/

Useful Options

# Dry run (see what would happen without executing)
s3cmd --dry-run put file.txt s3://BUCKET_NAME/

# Verbose output
s3cmd -v put file.txt s3://BUCKET_NAME/

# Force operation (skip confirmation)
s3cmd --force put file.txt s3://BUCKET_NAME/

# Show progress
s3cmd --progress put large_file.dat s3://BUCKET_NAME/

Quick Reference

Task Command
Create bucket s3cmd mb s3://BUCKET_NAME/
List buckets s3cmd ls
Upload file s3cmd put FILE s3://BUCKET_NAME/FILE
Download file s3cmd get s3://BUCKET_NAME/FILE LOCAL_FILE
Delete file s3cmd rm s3://BUCKET_NAME/FILE
Make public s3cmd setacl --acl-public -r s3://BUCKET_NAME/
Make private s3cmd setacl --acl-private s3://BUCKET_NAME/
Sync directory s3cmd sync LOCAL_DIR/ s3://BUCKET_NAME/REMOTE_DIR/