How to use S3cmd Command 15 best examples.

In this article we will cover the s3cmd command examples, there are 15 examples of how to use the s3cmd command.

S3 stands for Simple Storage Service where you can store any type of data.

Let’s look at how you can manage your files and folders with the S3cmd command-line tool in Linux.

So if you want to install the S3cmd command-line tool, refer to the link. There are 3 ways to install S3cmd on your Ubuntu System.

So the 15 best examples to access the s3cmd command-line tool,

  1. List the buckets in AWS S3.
  2. List all buckets in AWS S3.
  3. Create a bucket with the s3cmd command.
  4. How to download the file from s3cmd.
  5. How to Upload the files from s3cmd.
  6. Upload the folder with the s3cmd command.
  7. Delete the file with the s3cmd command.
  8. Delete the folder using s3cmd.
  9. Bucket delete using the s3cmd command.
  10. Copy files from one bucket to another.
  11. Move files from one bucket to another.
  12. How to check the storage usage with du.
  13. How to get information about the bucket.
  14. Download the larger file from the AWS S3 bucket.
  15. Upload the larger file to the AWS S3 bucket.

15 Best Examples to use AWS S3cmd command.

15 best examples to use AWS S3cmd command.

Example 1: How to List the buckets in AWS S3.

So to list the buckets with the s3cmd command we have to use ls as an option.

$ s3cmd ls

Let’s suppose you have to look at one specific bucket named “tastethelinux” then,

$ s3cmd ls tastethelinux

Example 2: How to List all buckets in AWS S3.

To list all the buckets that are present on the AWS S3 bucket using the option ls.

$ s3cmd la

Example 3: How to Create a bucket with the s3cmd command.

So to create a bucket with the s3cmd command line use mb as an option. Suppose we have to create a bucket with the name “tastethelinux.”

$ s3cmd mb tastethelinux

Example 4: How to Download the file from s3cmd.

Now let’s have a look at how to download the files with the get option using s3cmd.

$ s3cmd get s3://tastethelinux/tla.txt

Example 5: How to Upload the files from s3cmd.

So in this example let’s upload the files with the put option using s3cmd.

$ s3cmd put tla.txt s3://tastethelinux/tla.txt

Here tla.txt is the is a file which is present on the local system, we have upload to “tastethelinux” bucket.


Example 6: How to Upload the folder by using the s3cmd command.

So to upload the folder with put option using s3cmd is very simple use of the recursive and job done.

$ s3cmd put tla_folder s3://tastethelinux/ -r

Folder tla_folder is present on the local system and let’s upload it to the bucket named “tastethelinux”. And -r is the recursive option that uploads the folder in the bucket.


Example 7: How to Delete the file with the s3cmd command.

Let’s see how to delete the file with the name “tla.txt” del as an option.

$ s3cmd del s3://tastethelinux/tla.txt

Example 8: How to Delete the folder using s3cmd.

Now we have to delete the Folder which is inside the tastethelinux bucket using del as an option.

$ s3cmd del s3://tastethelinux/Script

Example 9: How to Delete bucket using the s3cmd command.

So in this example, we have to delete the bucket “tastethelinux”. Be careful while deleting the buckets.

$ s3cmd rb s3://tastethelinux

Example 10: How to Copy files from one bucket to another.

Now let’s copy the files tla.txt from the tastethelinux bucket to the tastethelinux-example bucket.

$ s3cmd cp s3://tastethelinux/tla.txt s3://tastethelinux-example

So now we have 2 files, one file is in the tastethelinux bucket. And another is in a tastethelinux-example bucket with the same name.


Example 11: How to Move files from one bucket to another.

So to move the file from one bucket to another use mv as an option. We are going to move tla.txt to a tastethelinux-example bucket with a different name.

$ s3cmd mv s3://tastethelinux/tla.txt s3://tastethelinux-example/tla_new.txt

Example 12: How to check the storage usage with du.

Sometimes it happens that we have to check the S3 bucket usage. So for that, we have the du command which is as same as the Linux command.

$ s3cmd du s3://tastethelinux/ --human-readable

The –human-readable will show you the output in MB, GB or it can KB.


Example 13: How to get information about the bucket.

To get the information of the bucket using the option as info with the s3cmd command.

$ s3cmd info s3://tastethelinux

So, it will give the output as the location, expiration rule, and policy you have set on the buckets.


Example 14: How to Download the larger file from the AWS S3 bucket.

So let’s suppose you have a file size of around 40 GB. If you are facing a network issue, because of the network issue the download starts again and again.

So there is a way to avoid this circumstance by using –continue option.

$ s3cmd --continue get s3://tastethelinux/tastethelinux.tar.gz

Example 15: How to Upload the larger file to the AWS S3 bucket.

If you have to upload a larger file that is more than 600 GBs. But the Upload chuck size is 15 MB, so we are not able to upload a larger file. Then we have to increase the chunk size using –multipart-chunk-size-mb=SIZE.

$ s3cmd put --multipart-chunk-size-mb=20 tla_video.mp4 s3://tastethelinux/

So the tla_video.mp4 has been uploaded to the tastethelinux bucket. You can also use –help with the s3cmd for more options.

$ s3cmd --help

Thanks to read the article! Keep sharing and supporting!!!

Give your valuable time