A Debian-first guide to identifying packages that should not be present, reviewing install history, and removing software that increases risk or persistence.
Unexpected package installation means software was installed that does not fit the intended role of the Debian system. That can happen through rushed troubleshooting, misconfiguration, forgotten testing, or malicious activity after access is gained.
New packages matter because they can introduce services, binaries, dependencies, and attack surface that were never meant to exist.
sudo apt list --installed
sudo cat /var/log/apt/history.log
sudo grep -Ei "install|upgrade|remove" /var/log/dpkg.log
sudo systemctl list-units --type=service --state=running
sudo ss -tulnp
sudo grep -Ei "sudo|COMMAND" /var/log/auth.log
sudo systemctl stop <service_name>
sudo systemctl disable <service_name>
sudo ufw deny <port_number>
sudo ufw status numbered
sudo apt remove <package_name>
dpkg -L <package_name>
sudo systemctl list-unit-files --type=service
sudo find /etc -iname "*<package_name>*" 2>/dev/null
sudo grep -Ei "sudo|Accepted|useradd|adduser" /var/log/auth.log
getent group sudo
cut -d: -f1 /etc/passwd
Recovery means understanding whether the software was legitimately installed, accidentally left behind, or added as part of malicious activity.
sudo cat /var/log/apt/history.log
sudo systemctl list-units --type=service --state=running
sudo ss -tulnp
getent group sudo
sudo grep -Ei "sudo|COMMAND" /var/log/auth.log
sudo apt list --installed
sudo ufw status numbered
sudo ss -tulnp
Manual package and service review should come first. Future recommendations may include tooling that improves system visibility, but the best defense is keeping the Debian host lean, intentional, and well understood.
All commands shown are based on Debian-based systems unless otherwise noted.