You can run the lrb command to list buckets within one or more regions. The command returns basic bucket information, such as bucket names, creation time, storage classes, and the number of buckets.
Usage notes
To list buckets, you must have the oss:ListBuckets permission. For more information, see Attach a custom policy to a RAM user.
For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.
Command syntax
ossutil lrb conf_file [-e <value>]
The following table describes the parameters and options in the command syntax.
Parameter/Option | Description |
conf_file | If you want to list buckets within multiple regions, specify a local configuration file and enter the endpoints of these regions in the configuration file. Separate multiple endpoints with line feeds. |
-e | If you want to list buckets within a single region, set this parameter to the endpoint of the region. |
Examples
List buckets within a single region
The following command lists buckets within the China (Hangzhou) region:
ossutil lrb -e oss-cn-hangzhou.aliyuncs.com
List buckets within the region whose endpoint is specified in the ossutil configuration file. For more information about how to specify an endpoint in the ossutil configuration file, see config.
ossutil lrb
List buckets within multiple regions
Create a local file and specify the endpoints of these regions in the local file.
Create a local file named
localfile.txt
and specify the endpoints in the file. The following code provides an example on how to configurelocalfile.txt
:oss-cn-hangzhou.aliyuncs.com oss-cn-shenzhen.aliyuncs.com oss-cn-shanghai.aliyuncs.com
List buckets within the specified regions.
ossutil lrb localfile.txt
Sample output
After the command is successful, the output includes bucket names, creation time, storage classes, number of buckets, and time consumed to list the buckets. The following example is the output of the command to list buckets within multiple regions:
CreationTime Region StorageClass BucketName 2021-07-06 14:21:09 +0800 CST oss-cn-hangzhou Standard oss://examplebucket1 2021-07-06 14:21:44 +0800 CST oss-cn-hangzhou Standard oss://examplebucket2 2021-06-16 18:32:32 +0800 CST oss-cn-shanghai Standard oss://examplebucket3 2021-06-30 16:04:41 +0800 CST oss-cn-shanghai Standard oss://examplebucket4 2021-07-07 12:33:35 +0800 CST oss-cn-shenzhen Standard oss://examplebucket5 Bucket Number is: 5 0.124193(s) elapsed
Common options
If you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account.
The following sample command shows how to list buckets that are located in the China (Shanghai) region and owned by another Alibaba Cloud account:
ossutil lrb -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA**** -k 67DLVBkH7EamOjy2W5RVAHUY9H****
For more information about common options, see Common options.