I recently reinstalled Ubuntu (actually updated from 16.10 to 17.10) and while my Home directory is intact, any packages that were installed by me earlier are gone (not installed). However, it seems that their files are still on the disk. For example, I have the package zsh installed earlier, and now it's not installed. Still, there is a /usr/share/zsh folder containing lots of files.

I actually like the idea of starting from scratch with my packages, but I'm low on disk space. How can I completely remove all files leftover from the packages of the previous installation, without erasing any files needed for currently installed packages?

  • 1
    That will probably require you to scan practically every directory in /usr, /var, etc. It will be prohibitively expensive and possibly harmful, since some files might be generated and not included in the package file list. – muru Nov 6 '17 at 11:17
  • Well, what's the best I could do? Could I at least go by folders in /usr, /usr/share, /var`... how do I know which ones are not used, and where else to look? It's OK if I don't catch exactly everything. – Ludwik Nov 6 '17 at 11:21
  • 1
    Run dpkg -S /path/to/folder. If it's included in the filelist of an installed package, dpkg will report it. – muru Nov 6 '17 at 11:22
  • 1
    In /, /usr except /usr/local, places in /var like /var/lib, the /lib* directories, /sbin and /bin. – muru Nov 6 '17 at 11:47
  • 1
    I said In / ... what I meant was starting from there, look in those folders only. Leave the others alone. – muru Nov 6 '17 at 11:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.