Back to commands

Hosting Operations

Read-only, can be slow

Find Directories Burning Inodes

Inode usage is high and you need to locate which directories contain the most regular files.

Command

find /var/cache -xdev -type f -printf '%h\n' 2>/dev/null | sort | uniq -c | sort -nr | head

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 assume the largest count is safe to delete; identify the application owner and cache semantics first.

Expected output

A count of regular files grouped by parent directory, sorted highest first.

System impact

Read-only, can be slow. Nothing changes. The command counts files by parent directory.

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 when df -ih is high and large-file searches do not explain write failures.

When not to use it

Do not assume the largest count is safe to delete; identify the application owner and cache semantics first.

next steps

Related commands

Hosting Operations Can be slow

Summarize Cache File Ages

Cache cleanup is safer when you know whether files are stale or still active.

find /var/cache -xdev -type f -printf '%TY-%Tm-%Td\n' 2>/dev/null | sort | uniq -c
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
Hosting Operations Can be slow

Preview Old Temp Files Before Deleting

The safe version of cleanup is a candidate list first.

find /var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' 2>/dev/null | sort
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.