A Debian-first guide to identifying unexpected services, tracing their execution paths, and removing service-based persistence safely.
systemd services control what runs automatically on a Debian system. Attackers can abuse service units to create persistence, relaunch malware at boot, or hide execution behind service-like names that blend in with normal operations.
A malicious or unauthorized service may appear legitimate at first glance, especially if it uses a vague name or runs from an unusual path.
/tmp, user directories, or custom hidden pathssudo systemctl list-units --type=service --state=running
sudo systemctl list-unit-files --type=service | grep enabled
sudo systemctl status <service_name>
sudo systemctl cat <service_name>
sudo grep -R "ExecStart" /etc/systemd /lib/systemd 2>/dev/null
sudo journalctl --since "24 hours ago"
sudo systemctl stop <service_name>
sudo systemctl disable <service_name>
sudo systemctl mask <service_name>
Masking prevents the unit from being started normally while you investigate further.
file /path/to/binary
sha256sum /path/to/binary
strings /path/to/binary | less
sudo rm /etc/systemd/system/<service_name>
sudo systemctl daemon-reload
sudo find /etc/cron* -type f
sudo find /tmp /var/tmp /dev/shm -type f 2>/dev/null
cut -d: -f1 /etc/passwd
If a service was added maliciously, review who created it, what it launched, and whether it was paired with other persistence mechanisms.
sudo systemctl list-unit-files --type=service | grep enabled
sudo grep -R "ExecStart" /etc/systemd /lib/systemd 2>/dev/null
sudo systemctl list-units --type=service --state=running
sudo apt list --installed
sudo ufw allow from <trusted_ip> to any port 22
sudo ufw deny 22
sudo journalctl --since "24 hours ago"
Manual service review should come first. Future recommendations may include options that improve visibility into service changes or host behavior, but the core workflow remains Debian-first and transparent.
All commands shown are based on Debian-based systems unless otherwise noted. Unit file locations may vary depending on how the service was installed.