How do I get the users real uid if the program is run with sudo?

前端 未结 4 1632
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 20:52

The program I am running needs root privledges and therefore is run with sudo, but it also needs to know what user is running it. getuid and

4条回答
  •  孤街浪徒
    2021-01-07 21:12

    The easier way would be using Who am i

    who am i | awk '{print $1}'
    

    or

    who am i | cut -f1 -d" "
    

提交回复
热议问题