Step-by-Step Process for Common S3 CLI Commands
Step 1: Install and Configure AWS CLI
To Install AWS CLI follow below commands:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
To Configure AWS CLI follow below command
- Run below command to set up your credentials and default region
aws configure
Step 2: Common AWS S3 CLI Commands
- Create a Bucket: This command uses to Creates a new S3 bucket.
aws s3 mb s3://my-new-bucket --region
- List Buckets: By using this command we can check bucket list.
aws s3 ls
- List Objects in a Bucket: Lists all objects in the specified S3 bucket.
aws s3 ls s3://my-new-bucket
- Upload a File to a Bucket: By using this command we can upload file to specified S3 Bucket.
aws s3 cp myfile.txt s3://my-new-bucket/
- Download a File from a Bucket: To download file from the specified S3 bucket to current directory.
aws s3 cp s3://my-new-bucket/myfile.txt .
- Delete a File from a Bucket: To delete file from specified S3 bucket.
aws s3 rm s3://my-new-bucket/myfile.txt
- Delete a Bucket: To delete S3 Bucket.
aws s3 rb s3://my-new-bucket --force
- Sync Directories: Synchronizes the contents of my-local-dir with the specified S3 bucket.
aws s3 sync my-local-dir/ s3://my-new-bucket/
Use high-level (s3) commands with the AWS CLI
Amazon Simple Storage Service (Amazon S3) is a generally utilized, versatile, and highly dependable object storage service provided by Amazon Web Services (AWS). S3 allows you to store and recover any measure of data whenever, from anyplace on the web, while the AWS Management Console Center offers an easy to understand interface for managing S3, and the AWS Command Line Interface (CLI) gives a strong option in contrast to automation, scripting, and high level configurations.
Utilizing the AWS CLI, you can carry out various tasks, for example, creating and managing buckets, uploading and downloading files, setting bucket policies, and substantially more. This article plans to introduce you to the most widely recognized AWS S3 CLI commands, giving a far reaching manual for assist you with effectively dealing with your S3 resources from the command line. Whether you are a carefully prepared developer or a beginner cloud user, dominating these commands will fundamentally improve your capacity to interact with AWS S3.