How can I check if my program is running with root permission. Does Pathlib offer the possibility to query the USER-ID under Linux
You can access username with standard library package getpass
:
import getpass
print(getpass.getuser())
When code is executed with sudo or as root, the user is the string root
.