AWS CLI is a command-line interface for working with Amazon services. It provides a set of commands for managing files in cloud storage.
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.
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.
To retrieve a list of files, use the ls
command:
aws s3 ls s3://<bucket-name> --endpoint-url https://s3.hostman.com
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
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
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.