Skip to main content

du

The du ( Disk Usage) command is used to estimate and display the amount of disk space used by files and directories on a Linux system.

It helps users and administrators identify which files or folders consume the most space.

CODE
du [options] [directory or filename] 

Common Options

Option

Description

-s

Displays the total disk usage of a specified directory (summary only).

-h

Shows sizes in a human-readable format (KB, MB, GB, etc.).

These options are often used together as du -sh to get a quick overview of a folder’s total size.

Example Usages

a. Display the total size of the current directory

CODE
du -sh 

Shows the total disk usage of the current directory in a readable format.

b. Display the size of a specific file or directory

CODE
du -sh filename 

Shows the disk usage for the specified file or folder.

c. Display the size of all files and subdirectories

CODE
du -sh * 

Lists disk usage for each item in the current directory (including files and subfolders).

Additional Notes

du calculates space usage recursively, so it can take time on large directories.

To include hidden files and directories, use:

CODE
du -sh .[!.]* * 

Combine with sorting to find the largest folders:

CODE
du -sh * | sort -hr | head -10 

Displays the top 10 largest directories in the current location.

References

Red Hat documentation: du command options

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.