Introduction to AWS S3 client command line

In this short article i will go over the basic command used to work with AWS S3 storage command line client.

For this you will need to install the AWS client first and and have an AWS account ready for use(Is Free and comes with a good amount of free EC2 hours to use).

To install the AWS client follow this article, is easy as 1,2,3 :).

 

So the S3 utility that comes with the AWs client is a powerful tool that will enable you to manage your AWs S3 buckets for the command line and also you can implement it using scripts and create automated tasks.

  I will start by creating a new bucket and from here execute some basic tasks and commands. 

Add a new bucket

  • use the mb(make bucket) option followed by the {URI}:://name_of_bucket

List Bucket details

  • you will use the ls option followed by the bucket name

Remove Bucket

  • use the rb(remove bucket) option followed by the {URI}:://name_of_bucket

Remove a bucket that contains files

  • use the rb(make bucket) option followed by the {URI}:://name_of_bucket  and the –force option.

-if you try to remove a bucket that contains files you will get the following error.

Add new objects to a bucket:

Adding a new object to a S3 bucket is quite easy and similar to the copy command from Linux (cp).

Similar Article  Creating and removing Google Storage Buckets using the gsutil tools

Syntax:

aws s3 cp source destination option

Examples:

Copy an object from one bucket to another

Copy an object from one bucket to the same bucket

Copy from a S3 bucket to a local folder

Sync the content of two buckets

  • the sync S3 option recursively copies new and updated files from the source directory to the destination.
Similar Article  Working with S3CMD tool on AWS S3 storage buckets

Syntax: 

aws s3 sync {source} {destination} {option}

Examples:

Sync the content of one local folder and a S3 bucket

 

I will post more advanced AWS S3 command line examples in the future articles.

 

   

I hope this was helpful and i appreciate if you would like, subscribe or share our posts. I it is just a click

clickhere

No Comments
Leave a Comment

%d bloggers like this: