Linux
Useful Linux filesystem commands
A compact cheat sheet of filesystem commands I keep coming back to on the terminal.
Moving around
pwd # where am I
ls -lah # long list, human sizes, include hidden files
cd - # jump back to the previous directory
Finding things
find . -name '*.log' # by name
find . -type f -size +100M # files larger than 100MB
grep -rn 'TODO' src/ # recursive search with line numbers
Disk usage
du -sh * # size of each item in the current directory
du -sh * | sort -h# same, sorted smallest to largest
df -h # free space per mounted filesystem
When a disk fills up, du -sh * | sort -h from the root of the offending mount finds the culprit fast.
Permissions
chmod +x script.sh # make executable
chmod 644 file # owner read/write, everyone else read
chown user:group file
