There is a large log file inside project, but ls -ldh project reports only a few bytes for the directory. The log has not vanished. ls and du are reporting different measures.
Why is the size from ls -ldh so small?
With ls -ldh project, -d shows the directory itself rather than listing its contents. Its displayed size is not the sum of files underneath project. The -h flag only makes the number easier to read; it does not change what is measured.
In the diagram, 128B is an example directory size from ls -ldh, not a total for its files. 640K from du -sh is an example of usage beneath the directory, including hidden entries. Actual values depend on the filesystem and allocation units.
For usage beneath the same directory, run du -sh project. -s produces a one-line summary, and -h formats the units for reading. Start there when you want to know how much space a directory tree uses.
Compare ls and du on a temporary directory
This exercise creates a new temporary directory with a 512 KiB log and a hidden 128 KiB cache. It does not touch an existing project or server file.
lab_dir=$(mktemp -d)
mkdir -p "$lab_dir/project/logs" "$lab_dir/project/.cache"
dd if=/dev/urandom of="$lab_dir/project/logs/app.log" bs=1024 count=512 2>/dev/null
dd if=/dev/urandom of="$lab_dir/project/.cache/index.bin" bs=1024 count=128 2>/dev/null
ls -ldh "$lab_dir/project"
du -sh "$lab_dir/project"
du -h -d 1 "$lab_dir/project" | sort -hrOn the filesystem used for the original test, ls -ldh showed 128B for project, while du -sh showed 640K. The final command listed the total and its immediate subdirectories from largest to smallest:
640K .../project
512K .../project/logs
128K .../project/.cacheThe 128B is the size ls reported for the directory itself. The 512 KiB log and 128 KiB cache appear in du's usage totals. Your numbers may differ because filesystem allocation differs.
How do you include hidden subdirectories?
du -sh project/* is convenient, but the * glob normally excludes names beginning with a dot, such as .cache. In this example, it would show only the 512K logs directory and omit the 128K hidden cache. The total of 640K then seems to disagree with the listed children.
du -h -d 1 project reports the specified directory and each immediate child, including the hidden one. sort -hr sorts human-readable units from largest to smallest. If du cannot read some paths because of permissions, do not treat its result as complete; inspect the errors and access permissions first.
df -h answers a different question: usage and free space for the whole filesystem. Use du to narrow down which directory grew, and df to check the device's overall free space. Their totals do not have the same scope.
Key takeaways
ls -ldh reports the directory entry's size, while du -sh reports disk usage underneath it. Use du -h -d 1 to inspect one level at a time, including hidden directories. Also check for unreadable paths before trusting a total.

