newgrp(1) on Solnix vs Linux and the BSDs
On Solnix, newgrp is the illumos /usr/bin/newgrp. It accepts both - and -l to simulate a login, and the shells sh, ksh and ksh93 each have a newgrp built-in that execs it. Linux documents only -, the BSDs only -l, and the pages differ on supplementary groups and on when a group password is requested.
The manual pages
- Solnix: newgrp(1) from
pkgs.solnix.illumos-world-man· illumos.org - Linux: newgrp(1) shadow-4.19.4
- FreeBSD: newgrp(1) 15.1-RELEASE
- NetBSD: newgrp(1) 11.0
- Standard: POSIX.1-2024 (IEEE Std 1003.1-2024),
newgrp
What Solnix runs
A default Solnix system runs the illumos /usr/bin/newgrp. No other variants are shipped. The sh, ksh and ksh93 built-ins are equivalent to exec newgrp (or exec /usr/bin/newgrp) with the same arguments, so inside those shells the current shell is replaced.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| Linux | login-environment flag | Solnix accepts both - and -l to reinitialise the environment as if the user logged in again. The Linux synopsis lists only -, with no -l. A script using newgrp -l fails to match the Linux synopsis.Source: Solnix newgrp(1) SYNOPSIS and OPTIONS (-l | -); Linux newgrp(1) SYNOPSIS and DESCRIPTION |
| FreeBSD, NetBSD | - form | The FreeBSD and NetBSD pages document only -l. Solnix and Linux document the bare - form. The BSD pages do not say whether - is accepted.Source: FreeBSD newgrp(1) SYNOPSIS; NetBSD newgrp(1) SYNOPSIS; Solnix newgrp(1) OPTIONS; Linux newgrp(1) SYNOPSIS |
| Linux, FreeBSD, NetBSD | supplementary groups | Linux newgrp tries to add the new group to the user's group set. FreeBSD and NetBSD restore supplementary groups when run with no operand. The Solnix page says only that real and effective group IDs change, and does not mention supplementary groups. Source: Linux newgrp(1) DESCRIPTION; FreeBSD newgrp(1) DESCRIPTION; NetBSD newgrp(1) DESCRIPTION; Solnix newgrp(1) DESCRIPTION |
| Linux | group password source and rules | On Solnix a password is demanded if the group has one and the user is not listed in /etc/group as a member. Linux also reads /etc/gshadow, skips the prompt for root, and denies a non-member when the group password is empty. The Solnix page mentions none of these.Source: Solnix newgrp(1) DESCRIPTION (password paragraph); Linux newgrp(1) DESCRIPTION |
| Linux, FreeBSD, NetBSD | setting a group password | The Solnix page says the only way to create a group password is passwd(1), then copying the hash from /etc/shadow to /etc/group, and calls group passwords antiquated. FreeBSD and NetBSD call them insecure and discourage them. Linux reads /etc/gshadow instead.Source: Solnix newgrp(1) DESCRIPTION; FreeBSD newgrp(1) BUGS; NetBSD newgrp(1) BUGS; Linux newgrp(1) DESCRIPTION |
| FreeBSD | setuid installation | The FreeBSD page says newgrp is normally installed without the setuid bit and must be enabled with chmod u+s /usr/bin/newgrp. The Solnix page does not discuss the install mode.Source: FreeBSD newgrp(1) BUGS; Solnix newgrp(1) (no such section) |
| Linux, FreeBSD, NetBSD | shell replaced even on error | Solnix always replaces the current shell with a new one, even for an unknown group, and resets unexported variables (PS1, PATH, HOME and so on) to defaults. NetBSD also always starts a new shell. FreeBSD attempts to start the shell regardless of group-change failure. The Linux page does not say. Source: Solnix newgrp(1) DESCRIPTION; NetBSD newgrp(1) DESCRIPTION; FreeBSD newgrp(1) EXIT STATUS; Linux newgrp(1) DESCRIPTION |
| FreeBSD, NetBSD | umask handling | FreeBSD -l sets the environment and umask as for a fresh login. NetBSD says the file creation mask stays unchanged. The Solnix page does not mention umask.Source: FreeBSD newgrp(1) -l; NetBSD newgrp(1) DESCRIPTION; Solnix newgrp(1) OPTIONS |
| Linux, FreeBSD | numeric group operand | Solnix and NetBSD document group as a name or a non-negative numeric ID. Solnix looks up a numeric string as a group name first and uses that name's ID if it exists. The Linux and FreeBSD pages say only 'group'. Source: Solnix newgrp(1) OPERANDS (group); NetBSD newgrp(1) DESCRIPTION; Linux newgrp(1) SYNOPSIS; FreeBSD newgrp(1) DESCRIPTION |
| Linux | exit status | Solnix returns the new shell's exit status if a shell was created, otherwise a value above 0. FreeBSD and NetBSD say the same. The Linux page has no exit status section. Source: Solnix newgrp(1) EXIT STATUS; FreeBSD newgrp(1) EXIT STATUS; NetBSD newgrp(1) EXIT STATUS; Linux newgrp(1) |
| Linux, FreeBSD, NetBSD | shell built-ins | The Solnix page documents newgrp built-ins for sh, ksh and ksh93, each equivalent to exec newgrp with the same arguments. The other pages in the bundle document only the standalone command. Source: Solnix newgrp(1) SYNOPSIS, sh/ksh/ksh93 Built-in; Linux, FreeBSD and NetBSD newgrp(1) SYNOPSIS |
Standards
- POSIX: newgrp is a POSIX.1-2024 utility.
- Solnix: ATTRIBUTES: Interface Stability is Committed for
/usr/bin/newgrp, ksh and sh, with Standard 'See standards(7)'. The ksh93 built-in is listed as Uncommitted. - FreeBSD: The newgrp utility conforms to IEEE Std 1003.1-2001 (“POSIX.1”).
- NetBSD: The newgrp command conforms to IEEE Std 1003.1-2001 (“POSIX.1”).
- Linux: The shadow-utils 4.19.4 page has no standards section in the bundle.
Writing portable scripts
- Use newgrp with at most a group operand in portable scripts. Linux documents only the - flag, the BSDs only
-l, and Solnix both. - Expect newgrp to replace the current shell, so do not rely on commands after it in the same shell. Run the commands that need the new group inside the new shell, or use a different mechanism.
Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.