AWS S3 CLI Commands Cheat Sheet: All You Need to Know
Tags: aws, cloud, webdev
Published: 2022-09-01 13:35:04

<!-- wp:paragraph -->
<p>AWS S3 is one of the most popular AWS service as of now. It is a highly available, durable and cost effective object storage in AWS cloud.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>As you know, you can create and manage your S3 buckets using various tools like AWS console, CLI, CloudFormation etc. . However, nothing beats the ease of AWS CLI when it comes to managing your bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Firing a CLI command is easy and quick.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In this post, we'll learn few most important S3 CLI commands that can help you while working with S3.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"backgroundColor":"pale-cyan-blue"} -->
<p class="has-pale-cyan-blue-background-color has-background"><strong>Suggested Read:</strong> <a href="https://cloudkatha.com/5-ways-to-create-and-manage-aws-resources/">5 Ways to Create and Manage Resources on AWS </a></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Prerequisite</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before you can use AWS CLI to manage  your bucket, you need to install CLI in your machine and configure it using your credentials(access key/secret key).</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Here is a step by step tutorial on how to do it - <strong><a href="https://cloudkatha.com/how-to-install-and-configure-aws-cli-on-windows/">How to Install and Configure AWS CLI in your System</a></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Note:</strong> If you don't use CLI on regular basis and just want to test few commands, there is a quicker option from AWS console itself. You can use AWS <strong>CloudShell</strong> which is shown in below screenshot. Click on that terminal icon on top menu of your AWS account and a ready to use terminal will open. This terminal already has CLI installed and is configured with your credentials.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3388,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-1.png" alt="" class="wp-image-3388"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"backgroundColor":"pale-cyan-blue"} -->
<p class="has-pale-cyan-blue-background-color has-background"><strong>Suggested Read:</strong> <strong><a href="https://cloudkatha.com/aws-cloudshell-cli-access-to-aws-resources-from-your-browser/">All You need to Know about AWS CloudShell - Your Browser Based CLI</a></strong></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Basic Overview of S3 and CLI with S3</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before getting started with CLI commands, we needs to know few basic terms of AWS S3.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>Bucket</strong>: It's a top level container in which you store your objects</li><li><strong>Objects: </strong>Any item that is stored in an S3 bucket</li><li><strong>Prefix: </strong>Any folder that you have in your bucket</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>You use <a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/index.html">aws s3</a> CLI command to create and manage your s3 bucket and objects.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is how the basic syntax looks like-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 &lt;Command&gt; &#91;&lt;Arg&gt; ...]</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>You can have multiple arg like --region , --recursive , --profile etc.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3403,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/test-s3.drawio-1.png" alt="" class="wp-image-3403"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>commands or operations that you can use(copied from AWS documentation)</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/cp.html">cp</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/ls.html">ls</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/mb.html">mb</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/mv.html">mv</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/presign.html">presign</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/rb.html">rb</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/rm.html">rm</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/sync.html">sync</a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/website.html">website</a></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>You can use <code>cp, <strong>mv</strong></code> and <code><strong>rm</strong></code> on one object or all objects under a bucket or prefix by using <strong>--recursive</strong> option. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>AWS S3 CLI Commands Cheat Sheet</h2>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true,"backgroundColor":"pale-cyan-blue"} -->
<ol class="has-pale-cyan-blue-background-color has-background"><li>Create a Bucket</li><li>List All The Bucket</li><li>List the Content of a Bucket</li><li>Copy Files<strong> </strong>to and from S3</li><li>Find Out Number of Objects and Total Size of a Bucket</li><li>Generate Pre-signed URL for an Object</li><li>Move File To or From S3 Bucket</li><li>Sync S3 Bucket with Another Bucket or Local Directory and Vice Versa</li><li>Delete a File from a Bucket</li><li>Delete All Files From a Bucket</li><li>Delete a Bucket</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>1. Create a Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You use <strong>mb</strong> command to create a bucket. <strong>mb</strong> stands for make bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Create a Bucket in Default Region</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 mb s3://bucket-name</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Above command creates a bucket in the default region configured in your CLI. If you want to create a bucket in a specific <strong><a href="https://cloudkatha.com/is-s3-region-specific-or-global-what-do-you-think/">region</a></strong> , specify --region as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Create a Bucket In Specific Region</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 mb s3://mybucket --region us-west-1</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p><strong>Example-</strong></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 mb s3://cloudkatha-cli-bucket</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3392,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/AWS-S3-CLI-Commands-Cheat-Sheet-All-You-Need-to-Know.png" alt="AWS S3 CLI Commands Cheat Sheet: All You Need to Know" class="wp-image-3392"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Note:</strong> Please note that, S3 bucket names are unique globally.  So if you create a bucket with name '<strong>abc</strong>', no body else can create the bucket with same name even in any other account. Therefore, always make sure to choose a unique name specific to your business like I added <em>cloudkatha</em> in my bucket name. And that way, it's unique to me.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"backgroundColor":"pale-cyan-blue"} -->
<p class="has-pale-cyan-blue-background-color has-background"><strong>Suggested Reading: <a href="https://cloudkatha.com/why-s3-bucket-names-are-unique-globally/">This is why S3 bucket name is unique globally</a></strong></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>2. List All The Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>s3 ls </strong>command lists all the buckets in your AWS account provided you have permissions to do so.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 ls</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>As you can see in below screenshot, it shows all the buckets in my account.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3409,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/AWS-S3-CLI-Commands-Cheat-Sheet-2.png" alt="AWS S3 CLI Commands Cheat Sheet 2" class="wp-image-3409"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>3. List the Content of a Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Lists the content of a bucket. Ideally, it lists all the objects and prefixes inside the bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 ls s3://bucket-name</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>For example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 ls s3://demo-talk-with-anu</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3410,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/AWS-S3-CLI-Commands-Cheat-Sheet-3.png" alt="AWS S3 CLI Commands Cheat Sheet 3" class="wp-image-3410"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Note:</strong> Please note that, using ls commands by default lists only object within folder and not subfolders so if you want to list them all, use below command-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 ls s3://demo-talk-with-anu --recursive</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>As you noticed, we have added --recursive option to previous command.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>4. <strong>Copy Files </strong>to and from S3</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We use s3 cp command to copy one object or multiple to and from s3 bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3><strong>Copy a Single File from Local to S3</strong></h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp localPath s3://bucket-name</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>For example -</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp sample.txt s3://demo-talk-with-anu</code></pre>
<!-- /wp:code -->

<!-- wp:heading -->
<h2><strong>Copy a Single File from S3 to Local</strong></h2>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp s3://bucket-name/filename.txt ./</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>for example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp s3://demo-talk-with-anu/sample.txt ./</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Here sample.txt is copied to the current working directory.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2><strong>Copy a Single File from S3 to S3</strong></h2>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp s3://bucket-name/example s3://my-bucket/</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp s3://demo-talk-with-anu/index.html s3://techtalk-with-preeti/</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3398,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-4-1024x159.png" alt="" class="wp-image-3398"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Copy Multiple Objects From One S3 Bucket to Another</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Copies all objects in s3://bucket-name/example into another bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp s3://bucket-name/example s3://my-bucket/</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>For example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 cp s3://demo-talk-with-anu/website s3://techtalk-with-preeti/</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Ideally, you can make your own combination of source and destination and copy objects to or from s3 bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>5. Find Out Number of Objects and Total Size of a Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Finding out the total size of bucket is quite a useful command and needed at times. You can use s3 ls command with <strong>--recursive</strong>, <strong>--summarize</strong> and <strong>--human-readable </strong>options like shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 ls s3://bucket-name --recursive --summarize --human-readable</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>For example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 ls s3://demo-talk-with-anu --recursive --summarize --human-readable</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3433,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-8.png" alt="" class="wp-image-3433"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>As you can see above, total number of objects and total size are returned as well in a easy to read format.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>6. Generate Pre-signed URL for an Object</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can use a presigned URL to grant access to an S3 object. You can also use&nbsp;<code>--expires-in</code>&nbsp;option to specify when presigned URL expires.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Default is 3600 seconds and Maximum is 604800 seconds.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 presign s3://bucket-name/filename.html</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 presign s3://demo-talk-with-anu/index.html</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3413,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-6-1024x163.png" alt="" class="wp-image-3413"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Note: As you can notice in above screenshot, AMz-Expires =  3600 is shown as that's the default value. You can provide your own value like-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 presign s3://demo-talk-with-anu/index.html --expires-in 604800</code></pre>
<!-- /wp:code -->

<!-- wp:heading -->
<h2>7. Move File To or From S3 Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You use <strong>s3 mv</strong> to move an object or file. <strong>s3 mv</strong> command moves a local file or S3 object to another location locally or in S3.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 mv source destination</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 mv sample.txt s3://mybucket/test2.txt</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p><strong>Note:</strong> As expected from move, this commands moves the object/file to destination and removes/deletes it from source.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>8. Sync S3 Bucket with Another Bucket or Local Directory and Vice Versa</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can sync  a local folder with s3 , an s3 prefix with local folder or s3 folder to another s3 folder.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In the below syntax snippet you can see all the source destination combo is given.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>  sync &lt;LocalPath&gt; &lt;S3Uri&gt; or &lt;S3Uri&gt; &lt;LocalPath&gt; or &lt;S3Uri&gt; &lt;S3Uri&gt;</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>For example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 sync s3://mybucket .</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>using above command, all the content of mybucket is downloaded in current directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syncs Two bucket mybucket1 and mybucket2</strong></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 sync s3://mybucket1 s3://mybucket2</code></pre>
<!-- /wp:code -->

<!-- wp:heading -->
<h2>9. Delete a File from a Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can delete a file from an s3 bucket using <strong>s3 rm</strong> command. This is how the syntax looks like-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rm s3://bucket-name/filename</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>For example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rm s3://demo-talk-with-anu/index.html</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3396,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-3.png" alt="" class="wp-image-3396"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>10. Delete All Files From a Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As we saw in previous example, we used <strong>s3 rm</strong> to delete a file. However, if you want to delete all the objects even present in subfolders, you can as usual use <strong>--recursive</strong> options.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rm s3://mybucket --recursive</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Example-</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rm s3://demo-talk-with-anu --recursive</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3401,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-5.png" alt="" class="wp-image-3401"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>11. Delete Bucket</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can use <strong>s3 rb</strong> command to delete a bucket. <strong>rb</strong> here stands for remove bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Delete an Empty Bucket:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rb s3://bucket-name</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>As you already know that if you try to delete an empty bucket, all goes well but if you try to delete a bucket which has some objects, above command is gonna fail.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to delete a bucket with objects, use --force option. Using <strong>--force</strong> option in the command will first delete all the object and prefixes and then deletes the bucket.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Delete a Bucket with Objects</strong></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rb s3://bucket-name --force</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Example</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>aws s3 rb s3://demo-talk-with-anu --force </code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":3415,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cloudkatha.com/wp-content/uploads/2022/08/image-7.png" alt="" class="wp-image-3415"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>As you can see in above screenshot, first three delete operation is fired and then remove_bucket operation.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p> In this post, we learnt some of the most used AWS S3 CLI high level commands to manage bucket and objects.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We also learnt that, few commands like <code>cp, mv</code> and <code>rm</code> can be used on one object or all objects under a bucket or prefix by using --recursive option.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Apart from that, there are quite a few options that you can use like --region, --profile, --dryrun etc.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Hope the post was useful to you.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Feel free to check the <a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/index.html">official documentation</a> for further details.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="using-s3-commands-managing-buckets-references">Resources</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>AWS CLI reference:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/index.html" target="_blank" rel="noreferrer noopener"><code>aws s3</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/cp.html" target="_blank" rel="noreferrer noopener"><code>aws s3 cp</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/mb.html" target="_blank" rel="noreferrer noopener"><code>aws s3 mb</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/mv.html" target="_blank" rel="noreferrer noopener"><code>aws s3 mv</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/ls.html" target="_blank" rel="noreferrer noopener"><code>aws s3 ls</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/rb.html" target="_blank" rel="noreferrer noopener"><code>aws s3 rb</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/rm.html" target="_blank" rel="noreferrer noopener"><code>aws s3 rm</code></a></li><li><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/sync.html" target="_blank" rel="noreferrer noopener"><code>aws s3 sync</code></a></li></ul>
<!-- /wp:list -->

This post was originally published at my blog [CloudKatha](https://cloudkatha.com). You can check it out for more of my works.

Hope you enjoyed reading this post.