Command line program - Check if run as superuser

Good morning everyone. I am still working on my new package manager for Linux. In some case, I need to check if my command line program was run with privilege or not. How can I do that ?

if LibC.getuid == 0
	puts "superuser"
	puts "not superuser"
1 Like

Thank you !

I have another question about that. If my program try to access to a file it don’t have the proper right, how can I know that ?

Depends on your exact use-case but probably one of these:

1 Like

An exception is thrown. Just rescue it.

1 Like

Why I didn’t think about that earlier :crazy_face: