Back to commands

Linux Survival Basics

Read-only, can be slow

Show Big Files in Human Units

You need to find large files and read their sizes without mentally converting bytes.

Command

find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'

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 broad scans casually on busy systems or slow disks, and do not delete files from this list without checking ownership and purpose.

Expected output

Large files listed with approximate MB sizes. On broad paths, output can be delayed while the read-only scan walks many files.

System impact

Read-only, can be slow. It is read-only: no files are edited or removed. It still scans the chosen path and sorts results, so broad paths can create disk I/O before the MB list appears.

May require elevated permissions on protected paths or service-owned files.

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

When to use it

Use this when disk cleanup needs fast human-readable ranking. Start with the smallest useful directory, then widen only if needed.

When not to use it

Do not run broad scans casually on busy systems or slow disks, and do not delete files from this list without checking ownership and purpose.

Recovery / rollback

No filesystem state is changed. If the scan is too expensive, stop it with Ctrl-C and rerun against a narrower path.

next steps

Related commands

Linux Survival Basics Can be slow

Find the Files Eating Your Disk

The disk was full, but guessing at folders was the slow part.

find /var -type f -printf '%s %p\n' | sort -nr | head -20
Linux Survival Basics Can be slow

Find the Largest CI Logs

Huge logs often point to loops, noisy tests, or runaway debug output.

find logs/ -type f -printf '%s %p\n' | sort -nr | head -10
Linux Survival Basics Can be slow

Count Source Files by Extension

A quick extension count can show whether expected content made it into the source tree.

find source -type f -printf '%f\n' | sed -n 's/.*\.//p' | sort | uniq -c | sort -nr
Hosting Operations Can be slow

Rank Old Cleanup Candidates by Size

The oldest file is not always the file that buys back meaningful space.

find /var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' 2>/dev/null | sort -nr | head
Hosting Operations Can be slow

Review Log Files Before Cleanup

Before truncating logs, prove which log files are large and how old they are.

find /var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' 2>/dev/null | sort -nr | head -50
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.

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

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