Managing Disk space

Managing disk space on your development machine/server can be pretty annoying if you don't know where to start. In this article I've compiled some important places to check, especially if your environment includes Docker, Python or Node.

Useful commands

  • Use df -h to see the full disk usage
  • Use du -sh <folder-name> to see the size of a certain folder

Development environment

Docker

  • docker system df - prints the size of images, containers and cache
  • docker builder prune - clears docker cache, used for image building (doesn't remove anything important)

Conda

  • conda clean --all - clean up all files that were left by removed environments
  • conda info --envs - list all environments
  • conda remove -n <env-name> --all - remove any unused environments

NVM

  • rm -rf ~/.nvm/.cache - clean nvm cache

MacOS

  • To look up which files on your system are taking the most space go to Settings > Storage > Documents > File browser. Then navigate the tree and remove unnecessary files
  • rm -rf ~/Library/Caches/* - deletes temporary caches for programs (you might have to re-log in)

Brew

  • Remove abandoned dependencies brew autoremove
  • Cleanup brew cleanup --prune=all --dry-run

Linux

  • rm -rf /tmp/* - remove temporary files

Journal logs:

  • journalctl --disk-usage - see the disk usage for logs
  • sudo journalctl --vacuum-time=7d - remove logs older than 7 days

APT

  • sudo apt-get clean and sudo apt-get autoclean - clean up unused files
  • Remove unnecessary packages:
    • sudo apt-get --dry-run autoremove --purge
    • sudo apt-get autoremove --purge