Linux – User & Sudoers Audit (Bash)

Below is a ready-to-use script. Review and adapt variables to your environment.

#!/usr/bin/env bash
set -euo pipefail
echo "== Users =="
cut -d: -f1,3,7 /etc/passwd | column -t
echo
echo "== Sudoers (files) =="
grep -R --line-number -E '^[^#].*ALL' /etc/sudoers /etc/sudoers.d || true
echo
echo "== Recent logins =="
last -n 20 || true
  

← Back to SQL