s3cmd工具使用

1. 安装s3cmd工具
[root@testserver01 ~]# yum install s3cmd

2. 配置s3cmd, 按提示输入相应的ak,sk,endpoint等信息
[root@testserver01 ~]# s3cmd --configure

3. s3cmd使用

[root@testserver01 ~]# s3cmd mb s3://abc      (创建一个桶)
Bucket 's3://abc/' created
[root@testserver01 ~]# vi policy.txt
[root@testserver01 ~]# cat policy.txt
{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "AllowPublicRead",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": [
        "s3:GetObject"
      ],
      "Resource": [
        "arn:aws:s3:::abc/*"
      ]
    }
  ]
}

[root@testserver01 ~]# s3cmd setpolicy ./policy.txt s3://abc    (为指定桶设置policy)
s3://abc/: Policy updated

[root@testserver01 ~]# s3cmd ls s3://abc   (ls 列出abc bucket下面的文件)
2024-03-02 12:38        42272  s3://abc/xxx.sql
2024-03-02 12:38        12566  s3://abc/pro_update.txt
[root@testserver01 ~]# s3cmd del s3://abc/xxx.sql    (删除桶里面某个文件)
delete: 's3://abc/microcloud.sql'
[root@testserver01 ~]# s3cmd ls s3://abc
2024-03-02 12:38        12566  s3://abc/pro_update.txt

[root@testserver01 ~]# ls
anaconda-ks.cfg  policy.txt
[root@testserver01 ~]# s3cmd put anaconda-ks.cfg s3://abc/    (往指定桶里面上传文件)
upload: 'anaconda-ks.cfg' -> 's3://abc/anaconda-ks.cfg'  [1 of 1]
 1515 of 1515   100% in    0s    27.43 KB/s  done
[root@testserver01 ~]# s3cmd ls s3://abc
2024-03-02 12:45         1515  s3://abc/anaconda-ks.cfg
2024-03-02 12:38        12566  s3://abc/pro_update.txt

[root@testserver01 ~]# s3cmd get s3://abc/pro_update.txt    (从桶里面下载文件)
download: 's3://abc/pro_update.txt' -> './pro_update.txt'  [1 of 1]
 12566 of 12566   100% in    0s  1446.60 KB/s  done
[root@testserver01 ~]# ls
anaconda-ks.cfg  policy.txt  pro_update.txt
[root@testserver01 ~]#

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值