未分類 12 5 月 2020 关于获取 unix 系统的用户 id 关于获取 unix 系统的用户 id 資深大佬 : vc131874 2 如果程序通过管理员身份运行,函数 getuid()获取到的是 0,也就是 root 用户的 uid,但是我想要获取登录用户的 uid,有什么好的方式吗?比如我的登陆用户是 xx,我的程序需要管理员权限运行 sudo ./test ,在 test 程序中怎么获取 xx 的 uid 。 大佬有話說 (2) 資深大佬 : crab https://stackoverflow.com/questions/10272784/how-do-i-get-the-users-real-uid-if-the-program-is-run-with-sudo 主 資深大佬 : vc131874 @crab 感谢回复