Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Mac OS X Lion, given a group's GeneratedUID, what command can I do a reverse lookup and find the group name? DSeditgroup (group name) will give me the GUID, but I'm looking for the reverse.

Thank you in advance.

share|improve this question
add comment

1 Answer

Take a look at the getgrnam() or getgrgid() C functions included in Mac OS X.

See the getgrent manual page.

man getgrent

Also here is an example that needs some work, but something along these lines should allow given a GID number, lookup and print the group name.

#include <stdio.h>
#include <grp.h>

int main()
{
    struct group myGroup;

    struct group *grp;

    grp = &myGroup;

    grp = getgrgid(20); // <--- Enter your group ID number

    if (grp == NULL)
    {
        printf("Something went wrong\n");
    }

    printf("Group Name is: %s\n", myGroup.gr_name);
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.