How to remove all i386 packages from Ubuntu 64bit?

Solution 1:

The other automated solutions are dangerous and not always working (1), so here another way

sudo aptitude purge `dpkg --get-selections | grep ":i386" | awk '{print $1}'`

or

sudo apt-get purge `dpkg --get-selections | grep ":i386" | awk '{print $1}'`

(Try to use always and only one of the tools. Since aptitude is better when having dependency trouble, I prefer that.)

Good idea to also

dpkg --remove-architecture i386

and maybe

dpkg --print-foreign-architectures

(1) The other commands also lists packages having only i386 in their name (although they are for 64bit architecture), the regular expression didn't work and dpkg shows packages which are already removed, but still have configuration files left (dpkg -l shows "rc" instead of "ii" as status).

Solution 2:

I blitzed all my 32bit packages like this:

sudo apt-get remove `dpkg --get-selections | grep i386 | awk '{print $1}'`