thenorm
Posts: 11
Joined: Mon Feb 24, 2014 2:05 am

user ids

Fri Jun 16, 2017 3:13 am

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.

User avatar
rpdom
Posts: 15584
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: user ids

Fri Jun 16, 2017 5:44 am

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).

thenorm
Posts: 11
Joined: Mon Feb 24, 2014 2:05 am

Re: user ids

Sat Jun 17, 2017 1:35 am

Thanks

Return to “Troubleshooting”