Back to lessons

Hosting Operations

Risk: safe

Check Bytes and Inodes Before Cleanup

A host is failing writes and you need to know whether byte usage or inode usage is the tighter limit before deleting anything.

Command

df -h /lab/disk-inode-cleanup && df -ih /lab/disk-inode-cleanup

Before you run this

Risk: safe. Do not treat df output as a cleanup plan; it only identifies the pressured filesystem.

Expected output

Two filesystem tables: one for byte usage and one for inode usage.

System impact

Nothing changes. The command prints filesystem byte and inode summaries.

Recovery / rollback: no state is changed.

When to use it

Use at the start of disk incidents before deciding whether to hunt large files or huge counts of small files.

When not to use it

Do not treat df output as a cleanup plan; it only identifies the pressured filesystem.

Watch this command run

Example output from a temporary Linux lab

This example uses disposable sample files and sanitized output so you can inspect the shape of the result before touching a real system.

demo@lab:~$

$ df -h /work/disk-inode-cleanup

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        25G   19G  5G  80% /work
tmpfs           982M   12M  970M   2% /run

$ df -ih /work/disk-inode-cleanup

Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/vda1        25G   19G  5G  80% /work
tmpfs            245K    14  245K    1% /run
View reproducible demo details

This page shows the sanitized shell transcript and the setup steps needed to reproduce the example.

Lab setup steps

  1. df -h /lab/disk-inode-cleanup
  2. df -ih /lab/disk-inode-cleanup

next steps

Related commands

Hosting Operations Risk: safe

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 Risk: safe

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
Hosting Operations Risk: safe

Preview Old Temp Files Before Deleting

The safe version of cleanup is a candidate list first.

find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort
Hosting Operations Risk: safe

Summarize Cache File Ages

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

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
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:operations-deployment
  • lfcs:services-logs
  • 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.