When an account contains a large number of buckets, manual management becomes inefficient and error-prone. The bucket listing function allows you to obtain a list of all buckets under your account, making it easier to perform tasks such as bucket counting, batch operations, and permission audits. This improves both the efficiency and accuracy of bucket management.
Important Notes
Bucket listing requests default to the CN North-Beijing1 region. Therefore, the costs for the ListAllMyBucketsOperation requests are billed to this region. Listing buckets may also involve data transfer, which incurs traffic charges. For details, see Data Transfer.
Constraints
To list all buckets in an account, you must have the obs:bucket:ListAllMyBuckets permission for all buckets. For details, see Using IAM Roles or Policies to Grant Access to OBS. The following example shows an IAM policy that grants the obs:bucket:ListAllMyBuckets permission for all buckets.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | {
"Version": "5.0",
"Statement": [
{
"Effect": "Allow",
"Action": [
"obs:bucket:ListAllMyBuckets"
],
"Resource": [
"obs:*:*:bucket:*"
]
}
]
}
|
ListAllMyBuckets is considered high-risk because it may expose bucket names. Exercise caution when granting or using this permission.
Ways to List Buckets
You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to list buckets.
Using OBS Console
- In the navigation pane of OBS Console, choose Buckets.
- Go to the bucket list page, which shows all the buckets under your account.
Using the GUI Tool - OBS Browser+
Log in to OBS Browser+. After login, all buckets under your account are displayed in the bucket list.
Using the CLI Tool - obsutil
Command Line Structure
- Windows
obsutil ls [-s] [-fs] [-sc] [-du] [-fs] [-j=1] [-limit=1] [-format=default] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- macOS or Linux
./obsutil ls [-s] [-fs] [-sc] [-du] [-fs] [-j=1] [-limit=1] [-format=default] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
Parameter Description
| Parameter | Optional or Mandatory | Description |
| s | Optional (additional parameter) | Displays simplified query result. NOTE: In the simplified format, the returned result contains only the bucket name. |
| sc | Optional (additional parameter) | Queries the storage classes of the buckets when listing buckets. |
| j | Optional (additional parameter). It must be used together with sc. | The maximum number of concurrent tasks for querying the bucket storage class. The default value is the value of defaultJobs in the configuration file. NOTE: The tool ensures that this value is at least 1. |
| du | Optional (additional parameter) | Quickly returns the total size of listed objects, without displaying detailed object information. This parameter can be used together with other parameters. NOTE: This parameter takes effect only on listing objects, but not on listing buckets. |
| fs | Optional (additional parameter) | Whether the method of listing parallel file systems is applied. If you are listing parallel file systems, you are recommended to add this parameter. CAUTION: - With this method, the listing time required varies largely depending on the directory structures.
- After this parameter is enabled, marker and limit will be ignored. Then, the size of the bucket, parallel file system, or directory will be calculated.
- This parameter is only supported by obsutil 5.5.12 and later.
|
| limit | Optional (additional parameter) | The maximum number of buckets that can be queried. If the value is less than 0, all buckets are listed. If it is left blank, a maximum of 1000 buckets can be listed by default. |
| format | Optional (additional parameter) | Prints a listing result in the user-defined format. Currently, the value can only be default, indicating that the listing result is displayed in one row. |
| config | Optional (additional parameter) | The user-defined configuration file for executing the current command. For details about parameters that can be configured, see Configuration Parameters. |
| e | Optional (additional parameter) | The endpoint |
| i | Optional (additional parameter) | The user's AK |
| k | Optional (additional parameter) | The user's SK |
| t | Optional (additional parameter) | The user's security token |
In a bucket listing result, BucketType indicates the bucket type. OBJECT indicates an object storage bucket, while POSIX indicates a parallel file system.
Logging and Monitoring
OBS provides logging and monitoring features that help you detect and handle deletion operations promptly. CTS can trace bucket-listing operations, including listAllMyBuckets and REST.GET.SERVICE. Bucket-listing logs provide detailed records for auditing or further analysis. For configuration details, see Monitoring and Logging.