Detect a user sudo-su'd into the current shell

last

[[ $(who -m | awk '{ print $1 }') == $(whoami) ]] || echo "You are su-ed to $(whoami)"

click the source code to copy install last on any operating system with command-not-found.com