Back to commands

Hosting Operations

Read-only, can be slow

Keep du on One Filesystem

You need a directory-level size view without crossing filesystem boundaries during disk triage.

Command

du -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h

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 recursive scans from / during a busy incident unless the extra I/O is acceptable.

Expected output

A human-readable size list for direct children under the selected var directory.

System impact

Read-only, can be slow. Nothing changes. The command measures apparent usage and keeps the scan on one filesystem.

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 after df identifies the pressured mount and you need a scoped directory ranking.

When not to use it

Do not run broad recursive scans from / during a busy incident unless the extra I/O is acceptable.

Recovery / rollback

No undo needed because du only reads metadata and file sizes.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

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

$ du -xh --max-depth=1 /work/disk-inode-cleanup/var 2>/dev/null | sort -h

8.0K	/work/disk-inode-cleanup/var/log
8.0K	/work/disk-inode-cleanup/var/tmp
664K	/work/disk-inode-cleanup/var/cache
684K	/work/disk-inode-cleanup/var
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. df -h /lab/disk-inode-cleanup
  2. du -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h

next steps

Related commands

Hosting Operations Can be slow

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 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

Review Log Files Before Cleanup

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

find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
Web Server Rescue Can be slow

Find Large Directories with du

Once you know a filesystem is full, the next question is where.

du -xh --max-depth=1 /var 2>/dev/null | sort -h
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: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.