我必须使用 sudo
来运行我的程序 :
sudo ./my_program
I am trying to run git clone
from my program, but it tries to use the root user s SSH keys instead of mine.
Is there a way to execute this single command as the user who originally invoked my program?
我想我可以做到这一点:
su - original_user -c "git --version"
但是,我该如何找到原始用户的用户名? 或者还有另一个优雅的解决方案吗?