How to verify uid -> username lookups? - Linux

This is a discussion on How to verify uid -> username lookups? - Linux ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: How to verify uid -> username lookups?

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

  2. Re: How to verify uid -> username lookups?

    On 2008-04-24, Greg Ercolano 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


  3. 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 to Thread