Back to practice tasks

practice task

Find the Largest Files Under /var

The root filesystem is nearly full and /var looks suspicious. You need a read-only way to find the biggest files without crossing into other mounted filesystems.

Independent study support only. No affiliation, endorsement, exam dumps, or guaranteed exam results.

Try first

find /var -xdev -type f -printf '%s %p\n' | sort -nr | head -20

Goal

List the largest regular files under /var and keep the search on the same filesystem.

Expected output

Rows beginning with byte counts followed by file paths, sorted from largest to smallest. Large logs, caches, or backups should stand out near the top.

Teaches

Use find for precise file selection and sort numerically before deciding what can be archived, truncated, rotated, or removed.

Common mistake

Using du on broad paths without -xdev and accidentally including backup mounts, container volumes, or network filesystems.

command set

Commands to know

  1. find /var -xdev -type f -printf '%s %p\n'
  2. sort -nr
  3. head -20
  4. numfmt --to=iec

Watch this command run

Example output from a temporary Linux lab

next practice

Read Recent Logs for One Service

A service restarted during deploy and is now unhealthy. You need the recent unit logs, not every log line on the machine.