du Command in Linux/Unix
The du
command in Linux/Unix stands for Disk Usage. It is used to check the disk space usage of files and directories on a system. The command provides information about the amount of disk space used by a particular file or directory.
Syntax
du [OPTION]... [FILE]...
Example:
du filename
Output Explanation
The du
command displays the disk space usage of the specified file or directory.
Options:
The du
the command supports various options to customize the output:
-a
or --all
: Display counts for all files, not just directories.
du -a
-h
or --human-readable
: Print sizes in human-readable format (e.g., 12K, 2M).
du -h
-c
or --total
: Display a grand total.
du -c
-s
or --summarize
: Display only the total for each argument.
du -s
-0
or --null
: Terminate lines with null bytes.
du -0
--block-size=<size>
: Set block size to <size>
.
du --block-size=1M
--time
: Display the modification time of the specified file or directory.
du --time
Example Usage:
$ du -h /path/to/directory
This command will display the disk space usage of the specified directory in a human-readable format.
Purpose and Usage:
The du
command is used to analyze and report on the disk space usage of files and directories. It helps users and system administrators to identify space-consuming files or directories on the system. By default, du
displays disk space usage in kilobytes. You can use options like -h
for human-readable format or specify --block-size
for a different block size.