All Products
Search
Document Center

Object Storage Service:du

Last Updated:Jun 02, 2026

The du command queries the total size of all objects in a bucket or directory.

Usage notes

Querying current-version object sizes requires the oss:ListObjects, oss:ListParts, and oss:ListMultipartUploads permissions. Querying all-version sizes requires the oss:ListObjectVersions, oss:ListParts, and oss:ListMultipartUploads permissions. For more information, see Grant a custom policy.

Command syntax

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

Parameter

Type

Description

prefix

string

The object directory or name prefix.

--all-versions

/

Queries the total size of all versions of the specified objects.

-d, --dirs

/

Lists objects and subdirectories in the current directory.

--encoding-type

string

Encoding method for object names. Valid value: url.

--end-with

string

Returns objects whose names are alphabetically before or equal to the specified value.

--exclude

stringArray

The exclusion rule for the path or object name.

--exclude-from

stringArray

Reads exclusion rules from a rules file.

--files-from

stringArray

Reads object names from a rules file. Empty and comment lines are ignored.

--files-from-raw

stringArray

Reads object names from a rules file.

--filter

stringArray

The filter rule for the path or object name.

--filter-from

stringArray

Reads filter rules from a rules file.

-f, --force

/

Runs the command without confirmation prompts.

--human-readable

/

Displays object sizes in human-readable units: KiB, MiB, GiB, TiB, or PiB.

--include

stringArray

The inclusion rule for the path or object name.

--include-from

stringArray

Reads inclusion rules from a rules file.

--list-objects

/

Uses the ListObjects operation to list objects.

--max-size

SizeSuffix

Maximum object size to include. Default unit: bytes. Supported units: bytes, KiB, MiB, GiB, TiB, PiB. 1 KiB = 1024 bytes.

--metadata-exclude

stringArray

The exclusion rule for object metadata.

--metadata-filter

stringArray

The filter rule for object metadata.

--metadata-filter-from

stringArray

Reads metadata filter rules from a rules file.

--metadata-include

stringArray

The inclusion rule for object metadata.

--min-age

Duration

Excludes objects modified more recently than the specified duration. Default unit: seconds. Example: 1h for one hour.

Note

--min-age 1h queries only objects modified one hour ago or earlier.

--max-age

Duration

Includes only objects modified within the specified duration. Default unit: seconds. Example: 1h for one hour.

Note

--max-age 1h queries only objects modified within the past hour.

--min-mtime

Time

Includes only objects modified after the specified UTC time. Example: 2006-01-02T15:04:05.

Note

--min-mtime "2006-01-02T15:04:05" queries only objects modified after 15:04:05 on January 2, 2006.

--max-mtime

Time

Includes only objects modified before the specified UTC time. Example: 2006-01-02T15:04:05.

--min-size

SizeSuffix

Minimum object size to include. Default unit: bytes. Supported units: bytes, KiB, MiB, GiB, TiB, PiB. 1 KiB = 1024 bytes.

--page-size

int

Maximum objects returned per page in paginated listing. Valid values: 1 to 1000. Default: 1000.

-r, --recursive

/

Runs the command recursively on all matching objects in the bucket. Without this flag, only objects in the specified path are processed.

--request-payer

string

Request payer. Set to requester if pay-by-requester is enabled for the bucket.

--start-after

string

Returns objects whose names are alphabetically after the specified value.

Note

For more information, see Command-line options.

Examples

  • Query total object size in a bucket

    ossutil du oss://examplebucket

    The output shows 13 objects (12 Standard, 1 Archive) totaling 132116024 bytes.

    storage class   object count            sum size
    ----------------------------------------------------------
    Standard        12                       132115210
    Archive         1                        814
    ----------------------------------------------------------
    total object count: 13                          total object sum size: 132116024
    total part count:   0                           total part sum size:   0
    
    total du size:132116024
    
    0.382978(s) elapsed
  • Query total object size in a directory

    ossutil du oss://examplebucket/desfolder

    The output shows 4 Standard objects totaling 92927 bytes in the desfolder directory.

    storage class   object count            sum size
    ----------------------------------------------------------
    Standard        4                       92927
    ----------------------------------------------------------
    total object count: 4                           total object sum size: 92927
    total part count:   0                           total part sum size:   0
    
    total du size:92927
    
    0.350440(s) elapsed
  • Query total size of .jpg objects in a directory

    ossutil du oss://examplebucket/desfolder --include *.jpg

    The output shows 1 Standard .jpg object totaling 92884 bytes.

    storage class   object count            sum size
    ----------------------------------------------------------
    Standard        1                       92884
    ----------------------------------------------------------
    total object count: 1                           total object sum size: 92884
    total part count:   0                           total part sum size:   0
    
    total du size:92884
    
    0.381506(s) elapsed
  • Query total object size and output in JSON format

    ossutil du oss://examplebucket/desfolder --output-format json

    The output shows 4 Standard objects totaling 92927 bytes in JSON format.

    {
      "ObjectCount": 4,
      "ObjectSize": 92927,
      "StandardObjectCount": 4,
      "StandardObjectSize": 92927,
      "Storage": 92927
    }
    0.508607(s) elapsed