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 # locatefind . -name '*.tmp' -exec rm {} + # then act (batched)
df -h # free space per filesystemdu -ah / | sort -rh | head # the biggest files/dirsWhat this lesson walks through
- 01Permissions: read the rwx triad
- 02find: locate, then act
- 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.