Page 1 of 1

user ids

Posted: Fri Jun 16, 2017 3:13 am
by thenorm
How can a script verify that the user is root? UID and EUID seem to always produce 0 and ROOT_EUID or ROOT_UID seem to be unknown.

Re: user ids

Posted: Fri Jun 16, 2017 5:44 am
by rpdom
thenorm wrote:How can a script verify that the user is root? UID and EUID seem to always produce 0 and ROOT_EUID or ROOT_UID seem to be unknown.
UID will produce 0 if the user is root or if using sudo. Otherwise it will be the UID of the actual user.

If using sudo, you can check SUDO_USER and SUDO_UID.

(I'm assuming you're talking about bash scripts here).

Re: user ids

Posted: Sat Jun 17, 2017 1:35 am
by thenorm
Thanks