This is a discussion on How to verify uid -> username lookups? within the Linux Administration forums, part of the Linux Forums category; id(1) on linux doesn't seem to allow a uid as an argument, even though the same command on ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
id(1) on linux doesn't seem to allow a uid as an argument,
even though the same command on osx/freebsd does. Is there some equivalent in linux? It's useful to be able to reverse-lookup uids into usernames when debugging weird admin issues with complex nsswitch/LDAP/pam configs. I know it can be done by writing a perl or c program using getpwuid(2), but I'm looking for something that is a one-command solution that comes standard with unix, and takes into account all possible username lookup configs (nis/ldap/passwd/nsswitch/pamd/etc) |
|
|||
|
On 2008-04-24, Greg Ercolano <erco@3dsite.com> wrote:
> > It's useful to be able to reverse-lookup uids into usernames > when debugging weird admin issues with complex nsswitch/LDAP/pam configs. You can use getent to get some or all of the entries from system databases: ~$ getent passwd root kkeller root:x:0:0::/root:/bin/bash kkeller:x:1000:100:,,,:/home/kkeller:/bin/bash getent queries all sources of information that you've configured, including NSS, PAM, and local files. man getent should have more info (though it doesn't on my current Slackware box, it does on my CentOS 4 box). --keith -- kkeller-usenet@wombat.san-francisco.ca.us (try just my userid to email me) AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt see X- headers for PGP signature information |
|
|||
|
Keith Keller wrote:
> You can use getent to get some or all of the entries from system > databases: > > ~$ getent passwd root kkeller > root:x:0:0::/root:/bin/bash > kkeller:x:1000:100:,,,:/home/kkeller:/bin/bash > > getent queries all sources of information that you've configured, > including NSS, PAM, and local files. man getent should have more info > (though it doesn't on my current Slackware box, it does on my CentOS 4 > box). Great. Yes, getent(1) appears to be the way to go. And yes, man pages for the command are thin on my fedora3 and ubuntu7 boxes as well: 'getent --help' shows -s/-V flags which aren't even mentioned in the manpage or info docs. |