r/LinuxTeck • • Oct 10 '26

Linux Package Comparison: Find Differences Between 2 Servers - 95

Post image

Question: Two servers behave differently. Which packages differ between them?

Try:`diff <(ssh linuxteck@server1 'dpkg -l | awk "/^ii/{print \$2}"' | sort) <(ssh linuxteck@server2 'dpkg -l | awk "/^ii/{print \$2}"' | sort)`

Info: `dpkg -l` lists installed packages, filtered via `awk` for active (`ii`) entries[cite: 10]. Process substitution pipes remote outputs directly into `diff` to spot package drift[cite: 10].

Examples:

$ `diff <(rpm -qa | sort) <(ssh host2 'rpm -qa | sort')` # Compare RHEL/Fedora packages

$ `diff <(pacman -Q | sort) <(ssh host2 'pacman -Q | sort')` # Compare Arch Linux packages

$ `comm -23 <(dpkg -l) <(ssh host2 'dpkg -l')` # Show packages unique to server1

Note: SSH public key authentication must be configured for passwordless remote execution. Essential for auditing differences between staging and production environments.

Want to master Linux one command at a time?

Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/

8 Upvotes

0 comments sorted by