We can also mount s3 bucket as local drive in our system using S3FS with FUSE. To configure it read next article mount s3 bucket on Linux.

s3cmd is available in default package repositories for the Ubuntu, Debian, Fedora, CentOS, and RHEL Linux systems. You can install it using simply executing the following commands on your system. If you are not getting the latest version of s3cmd using package managers, You can install the last s3cmd version on your system using the source code. Visit this url or use below command to download latest version of s3cmd. Then install it using the below command with source files.

Configure S3cmd Environment

After getting key files, use the below command to configure s3cmd.

Working with the s3cmd Command Line

Once the configuration is successfully completed. Now find below command details to how to manage s3 buckets using commands.

1. List All S3 Bucket

Use the following command to list all s3 buckets in your aws account.

2. Creating New Bucket

Below command will upload file file.txt to s3 bucket using s3cmd command. If we need to upload entire directory use -r to upload it recursively as below. Make sure you are not adding a trailing slash in the upload directory named backup (eg: backup/), else it will upload only content to the backup directory only. List the objects of s3 bucket using ls switch with s3cmd. Sometimes if we need to download files from the s3 bucket, Use the following commands to download them. You can also remove a file or a directory from s3 bucket. Read the below examples to delete a file or a directory from an s3 bucket with s3cmd. To Remove file from s3 bucket: Removing directory from s3 bucket: If we don’t need s3 bucket anymore, we can simply delete it using the following command. Before removing the bucket make sure it is empty. Above command failed because of s3 bucket was not empty To remove the bucket first remove all objects inside the bucket and then use the command again. Thanks for using this article. If you want to mount s3bucket in your system, you can article Mount S3bucket in Linux using s3fs. Also you can sync data between s3 bucket and local directory using s3cmd.

How To Install s3cmd in Linux and Manage S3 Buckets   TecAdmin - 23