krlaboratories

how check diskspace in linux

Jan 30th, 2022 (edited)
597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. df -h - show filesystem free space
  2. du -sh - show current directory size
  3. du --max-depth=1 -h - show size subdirs max to 1 level
  4. df -T - show disks type
  5. du -h | sort -rn - show filesize all dirs and sorting by size
  6. lsblk - show disks tree
  7. ls -l --block-size=G - list files with size in Gigabytes
  8.  
  9. /* Bash script for notification about critical disk space */
  10.  
  11. #!/bin/bash
  12. CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
  13. THRESHOLD=90
  14. if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
  15. mail -s 'Your disk space finished' -r admin@example.com << EOF
  16. Stats: $CURRENT%
  17. EOF
  18. fi
Add Comment
Please, Sign In to add comment