All Products
Search
Document Center

Object Storage Service:ls (List resources under the account level)

Last Updated:May 15, 2025

When you need to query and manage OSS resources under your account, such as querying and deleting large files, you can use the ls command to list buckets, objects, and parts in your current account.

Considerations

  • To list buckets, you must have the oss:ListBuckets permission.

  • To list objects, you must have the oss:ListObjects permission.

  • To list all versions of objects, you must have the oss:ListObjectVersions permission.

  • To list all parts, you must have the oss:ListParts and oss:ListMultipartUploads permissions.

For more information, see Grant custom permissions to RAM users.

Command syntax

ossutil ls [oss://bucket[/prefix]] [flags]

Local option

Type

Description

--all-versions

/

Specifies all versions of an object.

-d, --dirs

/

Returns objects and subdirectories in the current directory, instead of recursively displaying all objects in all subdirectories.

--encoding-type

string

The encoding method of object names. Valid value: url.

--end-with

string

Matches objects whose names are lexicographically before the value of this option.

--exclude

stringArray

The exclusion rule for paths or object names.

--exclude-from

stringArray

Reads exclusion rules from a file.

--files-from

stringArray

Reads a list of source object names from a file, with empty lines and comment lines ignored.

--files-from-raw

stringArray

Reads a list of source objects from a file.

--filter

stringArray

The filter rule for paths or object names.

--filter-from

stringArray

Reads filter rules from a file.

-f, --force

/

Forces an operation without requiring user confirmation.

--include

stringArray

The inclusion rule for paths or object names.

--include-from

stringArray

Reads inclusion rules from a file.

--limited-num

int

The maximum number of results to return.

--list-objects

/

Specifies that the ListObjects operation is called to list objects.

--max-size

SizeSuffix

The maximum size of an object that can be transferred. By default, the size is in bytes (B). You can suffix the numerical value with a 1024-based unit: B for byte, K for Kibibyte, M for Mebibyte, G for Gibibyte, T for Tebibyte, or P for Pebibyte.

--metadata-exclude

stringArray

The exclusion rule for object metadata.

--metadata-filter

stringArray

The filter rule for object metadata.

--metadata-filter-from

stringArray

Reads the metadata filter rule from a file.

--metadata-include

stringArray

The inclusion rule for object metadata.

--min-age

Duration

Lists only files that were modified before the specified time interval. The default unit is seconds. You can also use unit suffixes. For example, 1h indicates one hour.

Note

--min-age 1h lists only files that were modified more than 1 hour ago.

--max-age

Duration

Lists only files that were modified within the specified time interval. The default unit is seconds. You can also use unit suffixes. For example, 1h indicates one hour.

Note

--max-age 1h lists only files that were modified within the last hour.

--min-mtime

Time

Lists only files that were modified after the specified time. The time format is UTC. Example: 2006-01-02T15:04:05.

Note

--min-mtime "2006-01-02T15:04:05" lists only files that were modified after January 2, 2006, 15:04:05.

--max-mtime

Time

Lists only files that were modified before the specified time. The time format is UTC. Example: 2006-01-02T15:04:05.

--min-size

SizeSuffix

The minimum size of an object that can be transferred. By default, the size is in bytes (B). You can suffix the numerical value with a 1024-based unit: B for byte, K for Kibibyte, M for Mebibyte, G for Gibibyte, T for Tebibyte, or P for Pebibyte.

--multipart

/

Applies the operation to uncompleted multipart tasks within the bucket.

--page-size

int

The maximum number of objects that can be returned per page. Default value: 1000. Valid values: 1 to 1000.

-r, --recursive

/

Specifies recursion. When this option is specified, the command performs operations on all objects that meet the conditions in the bucket. Otherwise, the command performs operations only on the objects specified by the path.

--request-payer

string

The payer of the request. If pay-by-requester is enabled, specify this parameter. Valid value: requester.

--short-format

/

Displays items in the short format. If you do not specify this option, the long format is used.

--start-after

string

Matches objects whose names are lexicographically after the value of this option.

--resource-group-id

string

Specifies the ID of the resource group.

Note

For more information, see Command-line options.

Examples

  • List all buckets within the account.

    ossutil ls
  • List all objects in the examplebucket bucket.

    ossutil ls oss://examplebucket
  • List all objects with the name prefix "dir" in the examplebucket bucket.

    ossutil ls oss://examplebucket/dir
  • List all objects with the name prefix "dir" in the current directory of the examplebucket bucket.

    ossutil ls oss://examplebucket/dir -d
  • List the first 100 objects with the name prefix "dir" in the examplebucket bucket.

    ossutil ls oss://examplebucket/dir --limited-num 100
  • List all TXT objects in the dir1 and dir2 subdirectories of the root directory in the examplebucket bucket.

    ossutil ls oss://examplebucket/ --include "/dir1/**.txt" --include "/dir2/**.txt"
  • List all objects that were created within the last three days in the dir1 and dir2 subdirectories of the root directory in the examplebucket bucket.

    ossutil ls oss://examplebucket --include "/dir1/**" --include "/dir2/**" --max-age 3d
  • List all buckets and output the results in JSON format.

    ossutil ls --output-format json