When I am low on space or I just want to clean house:
Clean Packages
1. Update your sources.list
sudo apt-get update
2. Clean any partial packages left behind during an install
sudo apt-get autoclean
3. Clean your apt-cache
sudo apt-get clean
4. Remove any packages that are no longer necessary
sudo apt-get autoremove
5. Put it all together:
sudo apt-get autoclean && sudo apt-get clean && sudo apt-get autoremove
6. May show that you have broken packages or missing dependencies. Try fixing them with:
apt-get -f install
Note: You may receive the following error:
E: Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable)
E: Unable to lock the download directory
If you do, you can discover what is running and kill -9 the process. However, you could just wait until the installation is complete – or reboot.
ps faux | grep apt