A Debian-first guide to identifying suspicious sudo usage, reviewing elevated command execution, and containing unauthorized administrative activity.
Unauthorized sudo activity happens when elevated commands are run without a valid administrative reason. This may indicate compromised credentials, misuse by an unexpected user, or activity after privilege escalation.
Because sudo grants high-impact access, even a small number of suspicious commands deserves attention.
sudo grep -Ei "sudo|COMMAND" /var/log/auth.log
sudo grep -Ei "Accepted|session opened" /var/log/auth.log
getent group sudo
ps -U root -u root u
sudo ufw status numbered
sudo systemctl list-unit-files --type=service
sudo find /etc/cron* -type f
sudo passwd -l <username>
sudo chage -E 0 <username>
sudo deluser <username> sudo
sudo kill -TERM <PID>
sudo systemctl stop <service_name>
sudo grep -Ei "sudo|COMMAND" /var/log/auth.log
cut -d: -f1 /etc/passwd
getent group sudo
sudo ufw status numbered
sudo systemctl list-unit-files --type=service
sudo find /etc/cron* -type f
sudo find /home /root -name authorized_keys -type f -exec ls -lah {} \; -exec cat {} \;
ps auxf
sudo ss -tpn
Recovery means tracing what the sudo activity changed and whether it was part of a larger compromise chain.
getent group sudo
sudo grep -Ei "sudo|COMMAND|Accepted" /var/log/auth.log
sudo ufw allow from <trusted_ip> to any port 22
sudo ufw deny 22
sudo ufw status numbered
sudo systemctl list-unit-files --type=service
sudo find /etc/cron* -type f
ssh-copy-id user@server_ip
Manual sudo and auth review should come first. Future recommendations may include tools that improve visibility into privileged actions, but the strongest defense is still less exposure and fewer privileged accounts.
All commands shown are based on Debian-based systems unless otherwise noted.