Identify user in a Bash script called by sudo

前端 未结 7 2069
闹比i
闹比i 2020-12-07 14:39

If I create the script /root/bin/whoami.sh containing:

#!/bin/bash
whoami

and this script is called by a user with a properly

7条回答
  •  粉色の甜心
    2020-12-07 14:59

    who am i | awk '{print $1}' didn't work for me but who|awk '{print $1}' will serve the job

提交回复
热议问题