GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • w3resource
  • Front End
  • HTML
  • CSS
  • JavaScript
  • HTML5
  • Schema.org
  • php.js
  • Twitter Bootstrap
  • Responsive Web Design tutorial
  • Zurb Foundation 3 tutorials
  • Pure CSS
  • HTML5 Canvas
  • JavaScript Course

This view

  • Original page
  • New address

GeezerVison is showing www.w3resource.com — Python: Find group id, user id, real group id, supplemental group ids associated with the current process - w3resource

Python: Find group id, user id, real group id, supplemental group ids associated with the current process

Last update on May 17 2025 05:43:19 (UTC/GMT +8 hours)


Process Group and User IDs

Write a Python program to get the effective group id, effective user id, real group id, and a list of supplemental group ids associated with the current process.

Note: Availability: Unix.

Sample Solution:

Python Code:

# Import the 'os' module for operating system-related functions.
import os

# Print a newline for clarity.
print()

# Get the effective group ID and print it.
print("Effective group id: ", os.getegid())

# Get the effective user ID and print it.
print("Effective user id: ", os.geteuid())

# Get the real group ID and print it.
print("Real group id: ", os.getgid())

# Get the list of supplemental group IDs and print them.
print("List of supplemental group ids: ", os.getgroups())

# Print another newline for clarity.
print()

Sample Output:

Effective group id:  1007                                          
Effective user id:  1006                                           
Real group id:  1007                                               
List of supplemental group ids:  [1007]  

Flowchart:

Flowchart: Find group id, user id, real group id, supplemental group ids associated with the current process.


For more Practice: Solve these Related Problems:

  • Write a Python program to get the user ID and group ID of a specific user.
  • Write a Python program to check if the current user has root privileges.
  • Write a Python program to get the list of all groups a user belongs to.
  • Write a Python program to get the username of the currently logged-in user.

Go to:

  • Python Basic Exercises Home ↩
  • Python Exercises Home ↩

Previous: Write a Python program to extract the filename from a given path.
Next: Write a Python program to get the users environment.

Python Code Editor:

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.


  • Daily Coding Challenges & Projects
  • Weekly Trends and Language Statistics



You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.