S3 cp Command Examples

The `s3 cp` command is a powerful tool for managing files and directories in Amazon S3 buckets using the AWS Command Line Interface (CLI). It allows you to copy files between your local machine and S3 buckets, as well as between two S3 buckets. Here, we'll explore the basics of the `s3 cp` command with detailed examples.

the command line chat sheet is shown in blue and white with yellow checkers on it
the command line chat sheet is shown in blue and white with yellow checkers on it

Before diving into the examples, ensure you have configured your AWS CLI with the necessary access keys and region. You can do this by running `aws configure` and following the prompts.

a black and white poster with text on it that says, sss chat sheet common commands
a black and white poster with text on it that says, sss chat sheet common commands

Basic Syntax and Usage

The basic syntax of the `s3 cp` command is as follows:

the basic commands for using command commands
the basic commands for using command commands

s3 cp [options]

Here, source can be a local file path, an S3 bucket path, or even another S3 bucket, while destination can be an S3 bucket path or another local file path.

Linux Terminal Customization Tips, Linux Networking Commands Cheat Sheet, Linux Terminal Prompt Customization, Polecenia Linux Cheat Sheet, Linux Kernel Module Programming Guide, Linux Terminal Coding, Linux Commands, Linux Chmod Command Guide, Linux Ls Command Output
Linux Terminal Customization Tips, Linux Networking Commands Cheat Sheet, Linux Terminal Prompt Customization, Polecenia Linux Cheat Sheet, Linux Kernel Module Programming Guide, Linux Terminal Coding, Linux Commands, Linux Chmod Command Guide, Linux Ls Command Output

Copying Local Files to S3

To copy a local file to an S3 bucket, use the following command:

s3 cp local-file.txt s3://my-bucket/

Command Prompt Commands: IT Tech Daily Copy‑Paste Toolkit
Command Prompt Commands: IT Tech Daily Copy‑Paste Toolkit

This command will upload the local file `local-file.txt` to the `my-bucket` bucket in the root directory.

Copying S3 Objects to Local

To download an S3 object to your local machine, use the following command:

Linux Customization, Black Arch Linux, Kali Linux Commands, Kali Linux, Hacking Books, Data Science Learning, Learn Computer Coding, Secret Websites, Linux Operating System
Linux Customization, Black Arch Linux, Kali Linux Commands, Kali Linux, Hacking Books, Data Science Learning, Learn Computer Coding, Secret Websites, Linux Operating System

s3 cp s3://my-bucket/remote-file.txt .

This command will download the `remote-file.txt` object from the `my-bucket` bucket to the current directory.

25 best Command Prompt (CMD) commands you should know
25 best Command Prompt (CMD) commands you should know
the ultimate guide to every cloude command
the ultimate guide to every cloude command
an image of the system command for windows and macosk, with instructions on how to use it
an image of the system command for windows and macosk, with instructions on how to use it
CMD COMMANDS
CMD COMMANDS
Command Line Cheat Sheet — Directory Navigation (2026)
Command Line Cheat Sheet — Directory Navigation (2026)
a laptop with the words list of 198 cmd command and prompt on it
a laptop with the words list of 198 cmd command and prompt on it
an orange and white poster with the words cmd commands on it's side
an orange and white poster with the words cmd commands on it's side
Common CMD commands everyone should know
Common CMD commands everyone should know
the essential guide to windows cmd commands you should know
the essential guide to windows cmd commands you should know
a poster with the words curl command chat sheet in blue and green font on it
a poster with the words curl command chat sheet in blue and green font on it
What is Command Prompt (CMD)?
What is Command Prompt (CMD)?
a block diagram showing the different types of commands used to create an application for dml
a block diagram showing the different types of commands used to create an application for dml
an info sheet with information about the ip command
an info sheet with information about the ip command
Useful window commands
Useful window commands
#itsupport #cmd #techtips #windowssupport | Badre Nagim
#itsupport #cmd #techtips #windowssupport | Badre Nagim
the linux command line is shown in this manual
the linux command line is shown in this manual
Grep Command with Examples
Grep Command with Examples
Learn the Basics of the chown Command
Learn the Basics of the chown Command
an image of a computer screen with the command window open
an image of a computer screen with the command window open
Client Challenge
Client Challenge

Working with Directories

The `s3 cp` command can also work with directories, recursively copying all files and subdirectories.

Copying Local Directories to S3

To upload a local directory to an S3 bucket, use the following command:

s3 cp local-directory/ s3://my-bucket/

This command will recursively upload all files and subdirectories in the `local-directory` to the `my-bucket` bucket.

Copying S3 Directories to Local

To download an S3 directory to your local machine, use the following command:

s3 cp s3://my-bucket/remote-directory/ .

This command will recursively download all files and subdirectories in the `remote-directory` from the `my-bucket` bucket to the current directory.

Copying Between S3 Buckets

You can also use the `s3 cp` command to copy objects between two S3 buckets.

Copying Objects from One S3 Bucket to Another

To copy an object from one S3 bucket to another, use the following command:

s3 cp s3://source-bucket/remote-file.txt s3://destination-bucket/

This command will copy the `remote-file.txt` object from the `source-bucket` bucket to the `destination-bucket` bucket.

Copying Directories Between S3 Buckets

To copy a directory from one S3 bucket to another, use the following command:

s3 cp s3://source-bucket/remote-directory/ s3://destination-bucket/

This command will recursively copy all files and subdirectories in the `remote-directory` from the `source-bucket` bucket to the `destination-bucket` bucket.

With these examples, you should now be well-equipped to use the `s3 cp` command for various file and directory management tasks in Amazon S3. Happy coding!