C#C
C#2y ago
6 replies
bakane

How to check if program is running as root on Linux

I need my program to be run as sudo to function, so I want to exit if it's not. How can I check if the program is running as root? I can't find any method that gets you the euid.
Was this page helpful?