All Products
Search
Document Center

Object Storage Service:Is

Last Updated:Dec 06, 2024

You can use the ls command in ossutil to list Object Storage Service (OSS) buckets, objects, and parts within an Alibaba Cloud account. For example, if you want to delete large objects within your account, you can first use the Is command to list objects within your account.

Usage notes

  • 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 Attach a custom policy to a RAM user.

Command syntax

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

Local option

Type

Description

--all-versions

/

Specifies all versions of an object.

-d, --dirs

/

Lists 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

Specifies an exclusion rule for paths or object names.

--exclude-from

stringArray

Reads exclusion rules from a file.

--files-from

stringArray

Reads object names from a file, with empty lines or comment lines ignored.

--files-from-raw

stringArray

Reads object names from a file, without ignoring empty lines and comment lines.

--filter

stringArray

Specifies a filter rule for paths or object names.

--filter-from

stringArray

Reads filter rules from a file.

-f, --force

/

Forces the operation without requiring confirmation.

--include

stringArray

Specifies an 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

/

Lists objects by calling the ListObjects operation.

--max-age

Duration

Excludes objects whose last modified time is earlier than the value of this option. The default unit is s (seconds). You can suffix the numerical value with a unit: ms for milliseconds, s for seconds, m for minutes, h for hours, d for days, w for weeks, M for months, or y for years.

--max-mtime

Time

Excludes objects whose last modified time is later than the value of this option. The time must be in UTC.

--max-size

SizeSuffix

The maximum size of a file or 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

Specifies an exclusion rule for object metadata.

--metadata-filter

stringArray

The filter rule for object metadata.

--metadata-filter-from

stringArray

Reads metadata filter rules from a file.

--metadata-include

stringArray

Specifies an inclusion rule for object metadata.

--min-age

Duration

Excludes objects whose last modified time is later than the value of this option. The default unit is s (seconds). You can suffix the numerical value with a unit: ms for milliseconds, s for seconds, m for minutes, h for hours, d for days, w for weeks, M for months, or y for years.

--min-mtime

Time

Excludes objects whose last modified time is earlier than the value of this option. The time must be in UTC.

--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 to return per page. Valid values: 1 to 1000. Default value: 1000.

-r, --recursive

/

Specifies that the command performs the operation recursively. If this option is specified, the command performs the operation on all matching objects in the bucket. If this option is not specified, the command performs the operation only on the specified object.

--request-payer

string

The payer of the request. If pay-by-requester is enabled, specify this option. 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

Specify the resource group ID.

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 within the account and format the output in JSON.

    ossutil ls --output-format json