Your cart is currently empty!
Drive Space Cheat Sheet for Linux/Ubuntu Machines
I find myself forgetting syntax when it comes to checking drive space and freeing space, here is a handy cheat sheet you hopefully will find handy for finding and cleaning up old data from your Ubuntu machine.
Note! Whenever cleaning up, take a backup first!
Checking Drive Space
df -h
: Check disk space usage in human-readable formatdf -i
: Check inode usage (number of files)du -sh /
: Estimate disk space usage of the root directorydu -sh ~
: Estimate disk space usage of your home directory
Finding Large Files and Directories
find / -type f -size +100M -exec ls -lh {} \;
: Find files larger than 100MBfind / -type d -size +100M -exec ls -lh {} \;
: Find directories larger than 100MBdu -a / | sort -n -r | head -n 10
: Show top 10 largest directories and files
Freeing Up Space
sudo apt autoremove
: Remove unnecessary packagessudo apt clean
: Remove package cachesudo rm -rf /tmp/*
: Remove temporary filessudo rm -rf ~/.cache/*
: Remove user cache files
Additional Tips
- Regularly clean up your
/var/log
directory to prevent log file buildup - Consider setting up a cron job to automate disk cleanup tasks
Remember to always be cautious when deleting files and directories, and make sure to backup your data before making any changes!
by
Tags:
Leave a Reply