Ubuntu – Accidentally deleted icons in /usr/share, how to get them back

icons

okay, so tyeing to type "icons" in the /usr/share/ directory, hit the delete key as root, now my icons are gone, all of them, the options for play in totem or the ones on the desktop….all of them, any help?

Best Answer

I like Bash porn so I wrote you a present:

for p in `dpkg -l | awk '/^ii  [^\ ]+/ {print $2}'`; do
    if [[ $(dpkg -L $p | grep /usr/share/icons/) ]]; then
        echo $p;
    fi;
done

That echos out all the installed packages that had files in /usr/share/icons/. If that works for you (it does for me) you can replace the echo statement with:

        sudo apt-get --reinstall install $p

It's going to use a lot of bandwidth and whatever you do, don't interrupt it, but it should get you all your packaged icons back.

Of course you can reverse that logic so you use something like this:

sudo apt-get --reinstall -s install $(for p in `dpkg -l | awk '/^ii  [^\ ]+/ {print $2}'`; do if [[ $(dpkg -L $p | grep /usr/share/icons/) ]]; then echo $p; fi; done)

The -s in there means simulation mode. That command won't actually do anything unless you remove the -s, it'll just show you what it would do. I'd probably recommend that before you jump in.


As Andrea points out dpkg -S can do all this on its own. Plus it's much quicker.

sudo apt-get -s --reinstall  install `dpkg -S /usr/share/icons/ | sed 's/,//g; s/\:.*$//'`
Related Question