Search code examples
pythonpython-os

Does os.getuid() == 0 mean the root user?


In some of the code, I have conditions on os.getuid() == 0. Does this mean the script is checking if the user is root and needs "sudo"


Solution

  • In a nutshell, yes. On systems where this makes sense at all, UID 0 implies the user is root, and that is what the code is checking.