getusershell(3)
๐ getusershell(3) ๐
okay bestie, listen โ this is getusershell / setusershell / endusershell from the Library Functions Manual, and it's literally the bouncer-at-the-club of Unix login shells. you in the libc? you're gonna wanna know who's allowed in. ๐
โจ NAME โจ
getusershell, setusershell, endusershell โ get permitted user shells ๐
๐ LIBRARY ๐
Standard C library (libc, -lc) โ the classic, no cap.
๐ฆ SYNOPSIS ๐ฆ
#include <unistd.h>
char *getusershell(void);
void setusershell(void);
void endusershell(void);
๐ธ Feature Test Macro Requirements for glibc ๐ธ
(peep feature_test_macros(7) if you need the lore, bestie)
getusershell(),setusershell(),endusershell():- Since glibc 2.21:
_DEFAULT_SOURCE
- In glibc 2.19 and 2.20:
_DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
- Up to and including glibc 2.19:
_BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
- Since glibc 2.21:
ngl the macro situation is giving โจgenerational traumaโจ but that's just how glibc grew up.
๐ DESCRIPTION ๐
so here's the tea.
The getusershell() function returns the next line from the file /etc/shells, opening the file if necessary. that line is supposed to contain the pathname of a valid user shell โ like, the receipts of who's even allowed to log in. ๐ซถ
And here's the iconic plot twist: if /etc/shells does not exist or is unreadable, getusershell() behaves as if /bin/sh and /bin/csh were listed in the file. so it just goes "fine, these two then" and carries on, main character energy fr fr. ๐ญ
The setusershell() function rewinds /etc/shells. โช rewinding the vibe check back to the start.
The endusershell() function closes /etc/shells. ๐ช and that's the door shut, bye.
๐ฅ RETURN VALUE ๐ฅ
The getusershell() function returns NULL on end-of-file. that's it, that's the whole clause. when the list runs out, it hits you with the NULL and you move on with your life. ๐
๐ FILES ๐
/etc/shells
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7). (iykyk)
- Interface:
getusershell(),setusershell(),endusershell()- Attribute: Thread safety
- Value:
MT-Unsafe
so uh, not thread safe, bestie. don't be sharing these across threads like they're a communal scrunchie. ๐
โญ STANDARDS โญ
None. ๐ not a single one. it simply is what it is.
๐ HISTORY ๐
4.3BSD. old money, honestly. vintage icon behavior. ๐
๐ซ SEE ALSO ๐ซ
and that's a wrap on getusershell(3)! remember: this whole page came straight from Linux man-pages 6.20, dated 2026-02-08. slay, stay safe, and keep your shells valid ๐โจ๐๐ฆ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms