Skip to content

Instantly share code, notes, and snippets.

@ngrogg
Last active May 22, 2024 04:13
Show Gist options
  • Save ngrogg/bb2f2d64fc20ea3ecf053070e6f02077 to your computer and use it in GitHub Desktop.
Save ngrogg/bb2f2d64fc20ea3ecf053070e6f02077 to your computer and use it in GitHub Desktop.
Some useful Linux disk space and inode commands

Some useful commands for Linux Disk and Inode space checking

Check disk space availability
df -h

Get size of folder
du -sh FOLDER

Get size of files in folder
ls -l --block-size=M
^^ Also works with G

Sort file size, largest first, human readable
ls -lSh

Sort file size, smallet first, human readable
ls -lShr

Check disk use (GB and MB)
du --max-depth=5 -chax 2>&1 | grep '[0-9\.]\+G' | sort -hr | head
du --max-depth=5 -chax 2>&1 | grep '[0-9\.]\+M' | sort -hr | head
^^ Works best from root '/' dir

check disk inode availability
df -i

Check folders using the most inodes:
find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n | tail -20
Replace with filepaths as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment