The os.geteuid()
method is used to extract the effective user ID of the current process. The inverse method of this function is seteuid()
, which is used to set the effective user ID. These methods are commonly found on
Note: The
OS
module in Python is used to deal with operating system commands.
What is meant by an “effective user ID”?
Effective user ID
os.geteuid()
N/A
: It does not take any argument value(s).
This method returns an effective user ID as an integer type.
Now, let’s see an example of this method.
# Program to show working of geteuid() method# importing mobulesimport osimport random# generating random number between 10-100euid = random.randint(10,100)# Assigning effective user id to current threados.seteuid(euid)# Extracting id to test this methodeuid= os.geteuid()# printing euid on consoleprint(euid)
os.geteuid()
method.