46

Over the time I installed many i386 packages, which I no longer need. How can I clean up the system and stay only with the amd64 packages?

1

6 Answers 6

42

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

3
  • 1
    Since you're using awk anyway, you may as well get rid of the grep invocation. Also, $() is preferable instead of backticks. I just got rid of my i386 packages using this command based on the one you gave: sudo apt purge $(dpkg --get-selections | awk '$1 ~ /:i386$/ { print $1 }') Commented Jan 26, 2017 at 23:54
  • The aptitude one works correctly. Commented Sep 19, 2022 at 22:42
  • 1
    This will break your Steam client, even if you installed the client for amd64 architecture, it still installs some 32-bit files and libraries to ensure compatibility with older games.
    – Gri Ma
    Commented Jul 12, 2023 at 6:23
24

I blitzed all my 32bit packages like this:

sudo apt-get remove `dpkg --get-selections | grep i386 | awk '{print $1}'`
4
  • 1
    how to make these kind of commands, i know apt-get and grep but whats awk'{print $1}', just want to know.
    – Sukupa91
    Commented Nov 27, 2013 at 2:07
  • awesome, and I was able to remove the i386 architecture now, but when I do dpkg -l | grep i386 to check the packages are still there any ideas, also +1 for the previouse comment and my guess it's related to shell scripting techniques Commented Jan 10, 2014 at 12:07
  • 1
    No responses probably because comments aren't the place for an awk tutorial. That bit of awk is printing only the first field of each line being piped in. Awk's default field separator is a space, " ".
    – rthbound
    Commented Jan 15, 2016 at 17:45
  • 1
    Finish it off with sudo dpkg --remove-architecture i386 Commented Apr 11, 2019 at 10:05
19

If they are not in your way, I would leave them where they are.

If you insist on deletion, use dpkg -l | grep i386 to create a list of i386-packages. You can delete these after careful checking with something like sudo apt-get purge <package-name>.

4
  • 2
    Except that aptitude is broken on multiarch, so that won't work so well :P
    – tumbleweed
    Commented Mar 19, 2012 at 19:43
  • apt-get purge <package-name> should still work, though. Commented Jun 15, 2012 at 9:53
  • 3
    "after careful checking" -- that is vague. Please be more clear.
    – kevinarpe
    Commented Feb 9, 2014 at 11:06
  • 1
    i have a i386 system on a usb sometimes i use it on amd64 machines , now i just wanted to do the inverse , so after running dpkg -l | grep amd64 i got an i386 pkg in my list which is amd64-microcode 3.20160316.3 i386 , i think that the ':' in the grep pattern is important ! (dpkg -l | grep ":amd64")
    – Yunus
    Commented May 24, 2017 at 16:13
16

The debian's multiarch guide mentions this command: apt-get purge ".*:<arch>", which would look like this for i386:

sudo apt-get purge ".*:i386"

You can then remove the architecture from dpkg:

sudo dpkg --remove-architecture i386
10

In case anyone is wondering, there's a much more sane and graceful way to do this. The last previous answer hopes to do the same thing, but that search fails since architectures are not actually part of package names, except in special cases.

as root (or with sudo) run:

aptitude remove ~i~ri386

If you don't use aptitude over apt-get already, do. It's really excellent. You can find a list of aptitude's search terms here.

6

There is another way of lower risk:

sudo apt-get remove "^.*:i386$"

This will specifically match only packages ending with ":i386", which is the standard naming convention for all i386 architecture Debian packages.

4
  • why remove over purge?
    – Lotus
    Commented Oct 7, 2015 at 15:16
  • 1
    @Lotus: I am unaware of the difference. Can you please explain? Maybe we can update this answer to improve it.
    – kevinarpe
    Commented Oct 8, 2015 at 1:41
  • purge takes the configuration files also and any remant directories iirc
    – Lotus
    Commented Oct 8, 2015 at 2:11
  • 2
    @Lotus I used purge and it worked on 14.04. This only worked for me after removing the quotation marks and carret. sudo apt-get purge .*:i386 Commented Mar 9, 2016 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .