Sign In
Sign In

AWS CLI is a command-line interface for working with Amazon services. It provides a set of commands for managing files in cloud storage.

Installation

To install AWS CLI on Ubuntu, use the command:

sudo apt install awscli -y

After installation, you can check the AWS version with the command:

aws --version

You can find information on installing AWS CLI on other operating systems in the AWS documentation.

Configuration

To configure AWS to work with our S3 object storage, use the command:

aws configure

An interactive prompt will appear, asking for connection credentials. Enter them as follows, using the values from your bucket settings in your control panel:

AWS Access Key ID [None]: <Access Key>
AWS Secret Access Key [None]: <Secret Access Key>
Default region name [None]: us-2
Default output format [None]: json

This will create a hidden .aws directory with config and credentials files, which contain AWS settings and authorization keys, respectively.

Working with Files

Retrieving a List of Files in a Bucket

To retrieve a list of files, use the ls command:

aws s3 ls s3://<bucket-name> --endpoint-url https://s3.hostman.com

Uploading a Local File to the Bucket

To upload files, use the cp command. In the example below, the test.txt file is uploaded:

aws s3 cp test.txt s3://<bucket-name> --endpoint-url https://s3.hostman.com

Deleting a File in the Bucket

To delete a file, use the rm command. In the example below, we delete test.txt:

aws s3 rm s3://<bucket-name>/test.txt --endpoint-url https://s3.hostman.com

Synchronizing Files

To sync files between a local directory (in this example, the current directory .) and the bucket, use the sync command:

aws s3 sync . s3://<bucket-name> --endpoint-url https://s3.hostman.com

You can find detailed information on these and other commands in the AWS documentation.

Was this page helpful?
Updated on 30 October 2024

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start
Email us
Hostman's Support