2

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
  • 2
    Please edit your question with the output of dpkg -S /usr/lib/gcc – steeldriver Jul 13 '16 at 14:51
  • ~$ dpkg -S /usr/lib/gcc gcc-5-base:amd64, libgcc-5-dev:amd64, cpp-5, gcc-5, gcc-6-base:amd64: /usr/lib/gcc – Anubhav Jul 13 '16 at 15:02
4

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')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.