fbpx
Essential AWS S3 Commands

1. Connect AWS S3

    1. Open Command Prompt

    2. run AWS Configure

    3. enter AWS Access Key ID

    4. enter AWS Secret Access Key

    5. Default region name – its shown by default for your account but you can enter it specifically for the Region you want to access the s3 bucket.

    6. default output format – json

      AWS Configure Command Prompt

2. List all S3 Buckets

    1. run command – aws s3 ls

      List S3 bucket

3. Create S3 Bucket

    1. run command – aws s3 mb s3://bucketcreationcli

      Create S3 Bucket
      Create S3 Bucket

      Syntax : aws s3 mb s3://<bucketname> | Note : Bucket name must be unique and must not contain spaces or uppercase letters.  See rules for bucket naming | for easy configuration of buckets with the permissions use AWS console for creating s3 bucket

4. Upload Folder with files inside it to S3 bucket from Local System

    1. change directory in command prompt where folder is located on local system; which needs to be uploaded to s3 bucket

      change directory in command prompt
      change directory in command prompt
    2. run command – aws s3 cp s3-uploadtesting s3://bucketcreationcli/s3-uploadtesting –recursive

      Upload Folder with files inside it to S3 bucket from Local System
      Upload Folder with files inside it to S3 bucket from Local System
       

      Syntax : aws s3 cp s3://<bucketname>/<foldername> –recursive

5. Download Folder with files inside it to Local System from S3 bucket

    1. run command – aws s3 cp s3://bucketcreationcli/ . –recursiveDownload Folder with files inside it to Local System from S3 bucket

      Download Folder with files inside it to Local System from S3 bucket

      Syntax : aws s3 cp s3://<bucketname>/ . –recursive

 

6. Upload Single file to S3 bucket in a specific Folder from Local System

    1. run command – aws s3 cp s3-uploadtesting\File.txt s3://bucketcreationcli/s3-uploadtesting/file.txtUpload Single file to S3 bucket in a specific Folder from Local System

      Upload Single file to S3 bucket in a specific Folder from Local System

      Syntax : aws s3 cp <foldername>\<filename> s3://<bucketname>/<foldername>/<filename>

7. Delete File from S3 Bucket

    1. run command – aws s3 rm s3://bucketcreationcli/”S3 Upload.txt”

      Delete File from S3 Bucket
       Delete File from S3 Bucket

      Syntax : aws s3 rm s3://<bucketname>/<“filename”>

8. Delete Folder with files inside it from S3 Bucket

    1. run command – aws s3 rm s3://bucketcreationcli/s3-uploadtesting –recursiveDelete Folder with files inside it from S3 Bucket

      Delete Folder with files inside it from S3 Bucket

      Syntax : aws s3 rm s3://<bucketname>/<filename> –recursive

9. Delete Specific file in a folder from S3 Bucket

      1. run command – aws s3 rm s3://bucketcreationcli/s3-uploadtesting/”s3 upload.txt”Delete Specific file in a folder from S3 Bucket

        Delete Specific file in a folder from S3 Bucket

         Syntax : aws s3 rm s3://<bucketname>/<foldername>/<“filename”>

Related Posts