setusershell(3)

setusershell3

Get valid user shells

Part of getusershell(3).

Usage

#include <unistd.h>

char *

getusershell(void);

void

setusershell(void);

void

endusershell(void);

Library

Standard C Library (libc, -lc)

Overview

The getusershell() function returns a pointer to a valid user shell as defined by the system manager in the shells database as described in shells(5). If the shells database is not available, getusershell() behaves as if /bin/sh and /bin/csh were listed.

The getusershell() function reads the next line (opening the file if necessary); setusershell() rewinds the file; endusershell() closes it.

Files

/etc/shells

Diagnostics

The routine getusershell() returns a null pointer (0) on EOF.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 42 times.

  1. 2.0.5–2.2.6
  2. 2.2.7–3.4
  3. 3.5–3.5.1
  4. 4.0
  5. 4.1–4.3
  6. 4.4
  7. 4.5–4.7
  8. 4.8–4.11
  9. 5.0–5.5
  10. 6.0–6.3
  11. 6.4
  12. 7.0
  13. 7.1
  14. 7.2
  15. 7.3
  16. 7.4
  17. 8.0
  18. 8.1
  19. 8.2
  20. 8.3
  21. 8.4
  22. 9.0
  23. 9.1
  24. 9.2
  25. 9.3
  26. 10.0
  27. 10.1
  28. 10.2
  29. 10.3
  30. 10.4
  31. 11.0
  32. 11.1
  33. 11.2
  34. 11.3
  35. 11.4
  36. 12.0
  37. 12.1
  38. 12.2
  39. 12.3
  40. 12.4
  41. 13.0–13.2
  42. 13.3–14.5
  43. 15.0–16.0

History

The getusershell() function appeared in 4.3BSD.

Bugs

The getusershell() function leaves its result in an internal static object and returns a pointer to that object. Subsequent calls to getusershell() will modify the same object.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.