Key Options
Combine various options of the `du` command to generate a disk usage report for your files and directories.
1. Basic Queries
2. Filtering and Output
3. Specifying a Path
Generated command:
Try combining the commands.
Description:
`du` Executes the command.
Combine the above options to virtually execute commands with AI.
Understanding the Output
The output of the `du` command primarily shows the disk usage of each file or directory.
Column | Description |
---|---|
Size | The disk space occupied by the file or directory (in human-readable format) |
Name | The name of the file or directory |
Difference between `du` and `df`
`du` (Disk Usage) measures the space occupied by specific files or directories on a disk. In contrast, `df` (Disk Free) shows the available space of the entire file system. `du` focuses on aggregating usage within the file system, while `df` focuses on the total capacity and free space of a mounted volume. Therefore, the results of the two reports may differ.
Usage Examples
Explore practical examples of the `du` command to efficiently analyze disk space usage.
Check total usage of the current directory in a human-readable format
du -sh .
Summarizes the total disk space occupied by the current directory in MB/GB units.
Check usage of subdirectories one level deep in the current directory
du -h --max-depth=1 .
Shows how much disk space each immediate subdirectory uses within the current directory.
Check usage of all files and directories in a specific directory
du -ah /var/log
Displays detailed usage for all files and subdirectories within the `/var/log` directory.
Check usage of the current directory, excluding the `.cache` directory
du -sh --exclude=".cache" .
Useful for calculating disk usage while excluding unnecessary cache directories.
Find the 10 largest directories
du -h . | sort -rh | head -n 10
Useful for finding the top 10 largest directories occupying the most space in the current directory.