How to verify uid -> username lookups?

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 ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-24-2008
Greg Ercolano
 
Posts: n/a
Default How to verify uid -> username lookups?

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)
Reply With Quote
  #2 (permalink)  
Old 04-24-2008
Keith Keller
 
Posts: n/a
Default Re: How to verify uid -> username lookups?

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

Reply With Quote
  #3 (permalink)  
Old 04-24-2008
Greg Ercolano
 
Posts: n/a
Default Re: How to verify uid -> username lookups?

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:18 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0