I am programming on a MacBook, hard drive has 128GB. Meanwhile for programming, you need to install a lot of software that takes up a lot of space, such as Xcode, Docker, VMWare. Therefore, I often receive notifications about Disk Storage on the system and have to delete old files that are no longer in use. I want to share with you some simple commands to increase the amount of free hard disk space.
Delete images and containers of docker
1 2 | docker system prune -f |
Delete node_modules without updating within 30 days
1 2 3 4 5 | ### Cleanup old node_modules echo "Cleaning node_modules in projects older than 30 days" find . -name "node_modules" -type d -mtime +30 | xargs rm -rf echo "Done cleaning node_modules" |
Homebrew cleaning
1 2 3 4 5 | # Clean up homebrew echo "Clean homebrew" brew update && brew upgrade && brew cleanup echo "Done cleaning homebrew" |
Delete the outdated gem
1 2 3 | # Clean up outdated gems gem cleanup |
If you are an ios developer, then you should delete the pod caches and the files that Xcode created during the build process:
1 2 3 | # Clean up pod caches rm -rf "${HOME}/Library/Caches/CocoaPods" |
1 2 3 | # Delete old XCode simulators xcrun simctl delete unavailable |
1 2 3 4 5 | # Clean up xcode junk rm -rf ~/Library/Developer/Xcode/Archives rm -rf ~/Library/Developer/Xcode/DerivedData rm -rf ~/Library/Developer/Xcode/iOS Device Logs/ |
Happy Coding!