Back to commands

Linux Survival Basics

Read-only

Spot Foreign-Architecture Packages

Package dependency output is confusing and you need to see whether the host has non-native architecture packages installed.

Command

dpkg-query -W -f='${Architecture}\t${Package}\n' | awk '$1 != "amd64" && $1 != "all"'

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not assume foreign architecture packages are wrong; some applications require them.

Expected output

Foreign-architecture package rows such as i386 zlib1g:i386.

System impact

Read-only. Nothing changes. dpkg-query prints package architectures and awk filters non-native rows.

Recovery / rollback: no state is changed.

When to use it

Use when debugging multiarch dependency issues, legacy runtime support, or unexpected i386 packages on amd64 servers.

When not to use it

Do not assume foreign architecture packages are wrong; some applications require them.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ dpkg-query -W -f='${Architecture}\t${Package}\n' | sort

amd64	base-files
amd64	bash
amd64	curl
amd64	libc6
amd64	linux-image-6.8.0-60-generic
amd64	nginx
amd64	openssl
amd64	python3
amd64	zlib1g
i386	zlib1g:i386

$ dpkg-query -W -f='${Architecture}\t${Package}\n' | awk '$1 != "amd64" && $1 != "all"'

i386	zlib1g:i386
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. dpkg-query -W -f='${Architecture}\t${Package}\n' | sort
  2. dpkg-query -W -f='${Architecture}\t${Package}\n' | awk '$1 != "amd64" && $1 != "all"'

next steps

Related commands

Linux Survival Basics Read-only

Find Broken or Leftover dpkg States

Not every package row is cleanly installed.

dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | awk '$1 !~ /^ii$/'
Linux Survival Basics Read-only

List Installed Package Versions

A package inventory beats memory when a server is drifting.

dpkg-query -W -f='${Package}\t${Version}\t${Architecture}\n' | sort
Linux Survival Basics Read-only

Find the Largest Installed Packages

Disk cleanup starts with evidence, not random package removal.

dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20
Linux Survival Basics Read-only

Find Which Package Owns a File

That binary came from somewhere. dpkg can tell you where.

dpkg-query -S /usr/sbin/nginx
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lpic1:102-package-management
  • lpic1:103-gnu-unix-commands
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • linuxplus:system-management
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.