linux · medium

Files, Permissions & Disk — find, chmod, du, df

Files, permissions and disk: chmod octal triads (x on a directory means traverse), find with -exec {} + for batched actions, and df (free per mount) vs du (biggest files) — plus the deleted-but-open cause of 'df full, du empty'.

🔑 Key line

chmod octal r=4 w=2 x=1 (750=rwx/r-x/---); x on a dir = traverse. find by -name/-size/-mtime then -exec {} + (batched). df -h = free per mount; du -ah | sort -rh | head = biggest files.

The code

chmod 750 file # rwx / r-x / --- (r=4 w=2 x=1)
chown user:grp f
find . -name '*.log' -size +100M -mtime +7 # locate
find . -name '*.tmp' -exec rm {} + # then act (batched)
df -h # free space per filesystem
du -ah / | sort -rh | head # the biggest files/dirs

What this lesson walks through

  1. 01Permissions: read the rwx triad
  2. 02find: locate, then act
  3. 03df vs du — and the space hog

chmod 750 = rwx owner / r-x group / none other (r=4 w=2 x=1). On a directory, x means 'enter', not 'run'.

See it animated — step by step, at your own pace

Unlock the full interactive walkthrough of Files, Permissions & Disk — find, chmod, du, df and 100+ animated C++ interview lessons.

← Previous
Text Processing — grep, awk, sed, pipes & xargs
Next →
Debugging: GDB — Crash Diagnosis, Breakpoints, Watchpoints, Core Dumps