du

Command Function

This command is used to query the disk space occupied by a file.

Syntax

du [-kKmh] [file...]

Parameters

Table 1 Parameter description

Parameter

Description

Value Range

--help

Displays the parameters supported by the du command.

N/A

-k

Displays the occupied blocks, each of which is 1024 bytes by default.

N/A

-K

Displays the occupied blocks, each of which is 512 bytes (POSIX).

N/A

-m

Displays the disk space in MB.

N/A

-h

Displays the disk space in human-readable format K, M, and G, for example, 1K, 243M, or 2G.

N/A

file

Specifies the target file.

N/A

Usage

  • The du command is used to obtain the disk usage of a file rather than a directory.
  • The value of file must be the file name. It cannot contain the directory where the file is located.

Example

Run du -h testfile.

Output

Command output

OHOS:/$ du -h testfile
1.8K    testfile