Saturday, June 29, 2019

16.04 - How to restore '/usr/lib/gcc/*'



On Ubuntu 16.04, I accidentally deleted my /usr/lib/gcc dir. I tried to reinstall gcc but the dir won't be created again. How do I restore.




~$ dpkg -S /usr/lib/gcc
gcc-5-base:amd64, libgcc-5-dev:amd64, cpp-5, gcc-5, gcc-6-base:amd64: /usr/lib/gcc


I recommend you to reinstall all packages on your system that are known to have files in the deleted /usr/lib/gcc directory.



The output of dpkg -S /usr/lib/gcc told us which packages this are, in your case:



gcc-5-base:amd64, libgcc-5-dev:amd64, cpp-5, gcc-5, gcc-6-base:amd64



Now let's reinstall all of them:



sudo apt-get install --reinstall gcc-5-base:amd64 libgcc-5-dev:amd64 cpp-5 gcc-5 gcc-6-base:amd64





You can alternatively automate this process and leave the parsing of the package list to sed.
That way you only have to run this single command:




sudo apt-get install --reinstall $(dpkg -S /usr/lib/gcc | sed 's/,\|: .*//g')

No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...