---
name: "getgrouplist"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/getgrouplist"
---

# getgrouplist(3)

produce a user's effective group list

## NAME

**getgrouplist** – produce a user's effective group list

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<unistd.h\>**

*int*\

**getgrouplist**(*const char \*name*, *gid\_t basegid*, *gid\_t \*groups*, *int \*ngroups*);

## DESCRIPTION

The **getgrouplist**() function retrieves from the group database the supplementary groups for the user specified in *name* and returns the effective group list, whose first group is the value of *basegid* and the others are the supplementary groups. *basegid* typically is the user's initial numerical group ID from the password database.

The effective group list is returned in the array pointed to by *groups*. The caller specifies the length of the *groups* array in the integer pointed to by *ngroups*. The number of groups of the effective group list, which may be greater than the *groups* array's length, is returned through *ngroups*.

## RETURN VALUES

The **getgrouplist**() function returns 0 on success and -1 if the length of the group list is too small to hold all the user's groups. In the latter case, the *groups* array is filled with as many groups as possible from the start of the effective group list, and the length pointed to by *ngroups* is set to the full length of the latter, thus to a value strictly greater than before the call.

## FILES

- */etc/group*

  group membership list

## SEE ALSO

[setcred(2)](/setcred/2.md), [setgroups(2)](/setgroups/2.md), [initgroups(3)](/initgroups/3.md)

## HISTORY

The **getgrouplist**() function first appeared in 4.4BSD.
