Back to commands

Apple Terminal

Read-only, can be slow

Find Which Folder Is Eating Disk Space

Disk space is low and the user needs to identify which project folder or cache is largest.

Command

du -sh ./* 2>/dev/null | sort -h

Before you run this

System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.

When not to use it: Do not run from the filesystem root expecting instant results. Start narrow.

Expected output

A human-readable sorted list such as 4.0K ./notes and 1.2G ./video-export.

System impact

Read-only, can be slow. Nothing changes. The command calculates and sorts apparent disk usage.

Scope this to the smallest useful path or service on busy systems.

Recovery / rollback: no state is changed.

When to use it

Use in Projects, Downloads, Desktop, or cache directories to find big items quickly.

When not to use it

Do not run from the filesystem root expecting instant results. Start narrow.

Explanation-only example

Illustrated output, not a live lab run

This example is intentionally illustrative. It shows the command shape without killing real processes or changing your machine.

demo@lab:~$

$ printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export'

4.0K ./notes
850M ./node_modules
1.2G ./video-export

$ printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export' | sort -h

4.0K ./notes
850M ./node_modules
1.2G ./video-export
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export'
  2. printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export' | sort -h

next steps

Related commands

Web Server Rescue Can be slow

Inspect Release Disk Usage

Disk pressure during deploys often starts in old release directories.

du -sh releases/* 2>/dev/null | sort -h | tail -10
Web Server Rescue Can be slow

Find Large Directories with du

Once you know a filesystem is full, the next question is where.

du -xh --max-depth=1 /var 2>/dev/null | sort -h
Hosting Operations Can be slow

Keep du on One Filesystem

A cleanup scan should not wander into mounted backups or network storage.

du -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lpic1:103-gnu-unix-commands
  • lpic1:104-filesystems-permissions-fhs
  • lfcs:essential-commands
  • lfcs:storage
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • linuxplus:system-management
  • linuxplus:troubleshooting
  • risk:macos-only
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.