Find out username and UID/GID

Gerrit Holl gerrit at nl.linux.org
Sun Jan 4 10:10:33 EST 2004


Florian Lindner wrote:
> how can I find out the username and it's UID and GID on a linux system,
> using the most recent python version? If possible, without the use of extra
> libraries.

>>> import os
>>> import pwd
>>> os.getuid()
500
>>> os.getgid()
500
>>> pwd.getpwuid(500)
('gerrit', 'x', 500, 500, 'Gerrit Holl', '/home/gerrit', '/bin/bash')

I think there is a simpler way for the last one in the docs, but I'm not
entirely sure.

yours,
Gerrit.

-- 
188. If an artizan has undertaken to rear a child and teaches him his
craft, he can not be demanded back.
          -- 1780 BC, Hammurabi, Code of Law
-- 
Asperger's Syndrome - a personal approach:
	http://people.nl.linux.org/~gerrit/english/




More information about the Python-list mailing list