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 delete files from this list without checking ownership and purpose.

Expected output

Large files listed with approximate MB sizes.

System impact

Read-only, can be slow. Nothing changes. The command converts byte counts into MB for quick triage.

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

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

Recovery / rollback: no state is changed.

When to use it

Use this when disk cleanup needs fast human-readable ranking.

When not to use it

Do not delete files from this list without checking ownership and purpose.

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:~$

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

196608 /var/cache/lab/blob.cache
98304 /var/log/app.log
65536 /var/backups/site.tar

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

0.2 MB /var/cache/lab/blob.cache
0.1 MB /var/log/app.log
0.1 MB /var/backups/site.tar

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

64K	/var/backups
96K	/var/log
192K	/var/cache
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. find /var -type f -printf '%s %p\n' | sort -nr | head -10
  2. find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'
  3. du -sh /var/* 2>/dev/null | sort -h

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 /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
Hosting Operations Can be slow

Find Directories Burning Inodes

Inode cleanup starts by finding the directory with too many files.

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
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
  • 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.