• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

“aws s3 cp” Command Examples

by admin

The aws s3 cp command is a part of the AWS Command Line Interface (CLI) and is used to copy local files or objects stored in Amazon S3 to another location, either locally or within Amazon S3 itself.

Here’s an overview of the aws s3 cp command and its functionality:

  • Copying Local Files to S3: The aws s3 cp command allows you to upload local files or directories to Amazon S3. You can specify the source file or directory on your local machine and provide the destination S3 bucket and key where the files should be uploaded.
  • Copying S3 Objects Locally: You can use the aws s3 cp command to download files or objects stored in Amazon S3 to your local machine. Simply specify the source S3 bucket and key, and provide the destination path on your local system where the files should be downloaded.
  • Copying Within S3: The aws s3 cp command also supports copying objects within Amazon S3 itself. You can specify the source S3 bucket and key as well as the destination bucket and key, allowing you to copy objects from one location to another within S3.
  • Recursive Copy: The aws s3 cp command provides an option to perform a recursive copy, allowing you to copy entire directories or folders and their contents. This is useful when you need to copy a large number of files or maintain the directory structure during the copy process.
  • Filtering Files: You can specify filters to include or exclude certain files or objects during the copy operation. This allows you to selectively copy files based on file extensions, prefixes, or other criteria.
  • Preserving Metadata: By default, the aws s3 cp command preserves the metadata (e.g., timestamps, permissions) of the source files or objects during the copy process. This ensures that the copied files retain the same attributes as the originals.

The aws s3 cp command provides a flexible and efficient way to copy files and objects between your local machine and Amazon S3, or within different locations in S3 itself. It is a powerful tool for managing data transfer to and from S3, enabling you to move, backup, and synchronize files with ease.

aws s3 cp Command Examples

1. Copy a file from local to a specific bucket:

# aws s3 cp /path/to/file s3://bucket_name/path/to/remote_file

2. Copy a specific S3 object into another bucket:

# aws s3 cp s3://bucket_name1/path/to/file s3://bucket_name2/path/to/target

3. Copy a specific S3 object into another bucket keeping the original name:

# aws s3 cp s3://bucket_name1//path/to/file s3:// bucket_name2

4. Copy S3 objects to a local directory recursively:

# aws s3 cp s3://bucket_name . --recursive

5. Display help:

# aws s3 cp help

Filed Under: AWS, Cloud, Linux

Some more articles you might also be interested in …

  1. vnstat Command Examples in Linux
  2. yum-config-manager: command not found
  3. fdupes: Finds duplicate files in a given set of directories
  4. tc Command Examples in Linux
  5. How to Copy / Move Files and Directories in Linux with “cp” and “mv” commands
  6. IBM DB2 Installation on Red Hat Enterprise Linux
  7. Understanding DM-multipath deamon (multipathd)
  8. nmcli: command not found
  9. Firewalld Command line Reference (Cheat Sheet)
  10. CentOS / RHEL : How to prioritize the devices used for swap partition

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright