Understanding the '--human-readable' Option in du Command

Abstract: Use du -h to display disk usage in intuitive units like KB and MB instead of raw bytes for easier interpretation.

Created: 2026-08-28 by
The du command in Linux calculates disk usage, but its default output consists of raw byte counts that are difficult for humans to interpret quickly. By appending the --human-readable flag (or its shorthand -h), you instruct the utility to automatically convert these large numbers into more intuitive units like kilobytes (K), megabytes (M), gigabytes (G), and terabytes (T). This simple modification transforms a wall of digits into a clear, digestible summary of your storage consumption, making it an essential tool for system administrators and developers who need to monitor space efficiently without manual calculation.

Basic Syntax and Usage

The most common way to use this option is by combining it with the target directory or file path. When you run the command without specifying a path, it defaults to the current working directory. The syntax is straightforward: type du, followed by the options, and then the target.

du --human-readable /path/to/directory

For example, if you want to check the size of your home directory, you would execute:

du --human-readable ~

This command will list every subdirectory within your home folder along with its respective size in human-readable format. The output is sorted by size, typically showing the smallest items first unless additional flags are used to reverse the order. Understanding this basic structure allows you to quickly assess which folders are consuming the most space on your system.

Shorthand Options and Common Variations

While --human-readable is explicit, the Linux community heavily favors shorthand flags for efficiency. The equivalent short form is -h. Using du -h produces identical results to du --human-readable but requires less typing. It is highly recommended to memorize this shortcut as it is frequently used in scripts and daily workflows.

Another critical companion flag is -s, which stands for "summarize." Without -s, du lists the size of every single subdirectory recursively, which can result in hundreds of lines of output for complex projects. Adding -s collapses all subdirectories into a single total size for the specified path. Combining these gives you the most useful one-liner for quick checks:

du -sh /var/log

This command provides just the total size of the /var/log directory in human-readable format, ignoring the internal breakdown. This combination is particularly effective when you only care about the aggregate footprint of a specific application or log partition rather than individual file distributions.

Understanding the Output Units

The human-readable format uses binary prefixes based on powers of 1024, not 1000. This distinction is important for technical accuracy. For instance, 1K represents 1,024 bytes, 1M represents 1,048,576 bytes, and so on. If you see an output like 4.5G, it means approximately 4.5 billion bytes, calculated using the binary standard.

Sometimes, you may encounter fractional values such as 3.2M. These decimals provide precision for sizes that do not divide evenly into the next unit. However, for very small files, the output might still show bytes if the size is less than 1K. In rare cases where you prefer decimal units (powers of 1000) for marketing or high-level estimation purposes, you can use the --si flag instead. This changes 1K to mean 1,000 bytes, aligning with SI standards often used in hard drive manufacturing specifications.

Advanced Filtering and Sorting

When dealing with massive directories, even human-readable output can be overwhelming. You can filter results using grep to find specific patterns. For example, to find only directories larger than 100M, you might pipe the output through grep and sort it manually, though this requires careful regex handling due to the variable string lengths of K, M, and G.

A more robust approach involves using the --max-depth option to limit how deep the command traverses the filesystem. Setting --max-depth=1 ensures that only immediate subdirectories are listed, preventing the output from diving too deeply into nested structures. This is useful for getting a high-level overview of a project's layout without getting lost in thousands of tiny configuration files.

Additionally, sorting the output can help prioritize cleanup efforts. While du does not have a built-in sort flag that works perfectly with human-readable strings, you can combine it with sort -h to arrange the results logically. The sort -h command understands human-readable suffixes and will correctly order 10M before 1G, whereas a standard alpha sort would place 1G before 10M because 'G' comes after '1' in ASCII tables. This synergy between du and sort creates a powerful pipeline for storage analysis.

Common Pitfalls and Best Practices

One common mistake is assuming that the sum of all subdirectory sizes equals the parent directory's size. Due to hard links and shared blocks, the numbers might not add up perfectly. Always trust the top-level summary provided by du -sh for accurate total usage. Another pitfall is running du on network mounts without caution; scanning NFS or SMB shares can be extremely slow and generate significant network traffic. It is best practice to specify exact paths rather than wildcards when possible to avoid unintended scans of large remote volumes.

If you need to exclude certain types of files, such as temporary caches, consider combining du with find to pre-filter the data before calculating size. This advanced technique ensures that you are only measuring relevant data. For routine monitoring, creating aliases for common commands like alias du='du -sh' in your .bashrc file can save time and reduce errors during daily maintenance tasks.

Frequently Asked Questions

Why does my du output still show bytes for small files?

The human-readable flag only converts sizes greater than or equal to 1 Kilobyte. Files smaller than 1,024 bytes remain displayed in their raw byte count to maintain precision. This behavior ensures that no data is lost for tiny configurations or logs.

How do I sort du output by size in descending order?

You should pipe the output to sort -hr. The -r flag reverses the order to show largest items first, while -h tells sort to understand human-readable suffixes. This combination provides a clear ranking of space consumers.

What is the difference between -h and --si flags?

The -h flag uses binary units (powers of 1024), which is standard for operating systems. The --si flag uses decimal units (powers of 1000), which matches manufacturer specifications for storage devices. Choose -h for system administration and --si for hardware comparisons.

Can du calculate size for multiple directories at once?

Yes, you can pass multiple paths as arguments to du. The command will list each directory separately and then provide a total line at the end if you use the -c flag. This is useful for comparing the sizes of different project folders side-by-side.

Why is du so slow on my server?

Slow performance usually indicates that du is scanning a vast number of small files or accessing slow network-mounted drives. Limiting the depth with --max-depth or excluding specific hidden directories can significantly speed up the process. Additionally, running the command with nice priority can prevent it from blocking other critical system operations.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More