When a user or a process tries to run something with sudo, the action is recorded in the system journal. Because sudo writes to the journal, you can filter on the SYSLOG_IDENTIFIER or MESSAGE fields to spot failed attempts, audit who tried what, and even trigger alerts.
Below is a step‑by‑step guide that shows how to:
- Identify failed
sudoattempts in real time - Pull historical data for a specific user or time window
- Distinguish between legitimate and suspicious activity
- Automate the process with a small script
- Understand trade‑offs and common pitfalls
The examples assume a recent systemd‑based distro (Debian 12, Ubuntu 24.04, Fedora 40, etc.) and that sudo is compiled with the default --syslog flag (enabled since 2019). If your system uses a custom sudo build or a different logging backend, the commands will need adjustment.