zlogin(1) on Solnix vs Linux and the BSDs

zlogin is the illumos command at /usr/sbin/zlogin. It runs a shell, a command or the console inside a zone named by zone name, and only the superuser in the global zone can use it. Linux nsenter and machinectl and FreeBSD jexec do similar jobs but take different arguments, and several single-letter flags mean something else.

What Solnix runs

A default Solnix system runs the illumos zlogin at /usr/sbin/zlogin. No other variants are shipped. The OpenBSD and NetBSD counterparts are not in the bundle, so this page compares only Linux and FreeBSD.

Differences

Compared withTopicWhat differs
Linux, FreeBSDhow the target is namedzlogin takes a zone name. FreeBSD jexec takes a jail id or name. Linux nsenter takes a target process with -t PID and the namespaces to enter. machinectl takes a machine NAME.
Source: Solnix zlogin(1) SYNOPSIS, OPERANDS; FreeBSD jexec(8) DESCRIPTION; Linux nsenter(1) -t, --target; Linux machinectl(1) SYNOPSIS
Linux-n meaningSolnix zlogin -n redirects stdin from /dev/null. Linux nsenter -n (--net) enters the network namespace. A script that passes -n to nsenter to stop it reading stdin will change namespaces instead.
Source: Solnix zlogin(1) -n; Linux nsenter(1) -n, --net
Linux-C meaningSolnix zlogin -C connects to the zone console. Linux nsenter -C (--cgroup) enters the cgroup namespace.
Source: Solnix zlogin(1) -C; Linux nsenter(1) -C, --cgroup
FreeBSD-l, -d and -u meaningszlogin -l username picks the zone user, and -d disconnects from the console when the zone halts. jexec -l gives a clean environment, -d sets the working directory, and -u/-U choose the user.
Source: Solnix zlogin(1) -l, -d; FreeBSD jexec(8) -l, -d, -u, -U
Linux, FreeBSDdefault userzlogin uses "root" unless -l is given. jexec -u, the default, takes a user name from the host environment, and -U takes one from inside the jail. machinectl shell --uid defaults to root. The nsenter text in the bundle does not say.
Source: Solnix zlogin(1) -l; FreeBSD jexec(8) -u, -U; Linux machinectl(1) --uid
Linux, FreeBSDlogin setup and environmentInteractive zlogin runs login(1) on a new pseudo terminal. With a utility it runs su(8) to set up a login environment. jexec gets a clean environment only with -l, which sets PATH to /bin:/usr/bin. The nsenter text does not describe the environment.
Source: Solnix zlogin(1) Interactive Mode, Non-Interactive Mode; FreeBSD jexec(8) -l
Linux, FreeBSDcommand is a shell stringIn non-interactive mode zlogin passes the command as a string interpreted by a shell in the zone (see rsh(1)). The jexec and nsenter pages describe a program with arguments and do not say a shell interprets it.
Source: Solnix zlogin(1) Non-Interactive Mode; FreeBSD jexec(8) SYNOPSIS; Linux nsenter(1) SYNOPSIS
Linux, FreeBSDno command givenzlogin with no utility and a tty on stdin starts an interactive login. jexec runs the user's shell. nsenter runs "${SHELL}" (default /bin/sh).
Source: Solnix zlogin(1) Interactive Mode; FreeBSD jexec(8) DESCRIPTION; Linux nsenter(1) DESCRIPTION
Linux, FreeBSDexit statusOnly in non-interactive mode does zlogin return the utility's exit status. In interactive and console modes it exits 0 unless a connection error occurs. It exits 1 on permission denied or failure to enter. The jexec page has no exit status section.
Source: Solnix zlogin(1) EXIT STATUS; FreeBSD jexec(8) (no EXIT STATUS section)
Linux, FreeBSDconsole and safe modezlogin -C attaches to the zone console, which persists across zone reboots. -S does minimal processing without login(1) or su(8), to recover a damaged zone. The jexec page has no console or safe-login option.
Source: Solnix zlogin(1) Console Mode, -S; FreeBSD jexec(8) OPTIONS
Linux, FreeBSDescape sequenceszlogin treats lines starting with ~ as escape sequences. ~. disconnects without warning to the zone. -e c changes the escape character and -E disables it. The jexec page documents no escape sequences.
Source: Solnix zlogin(1) -e, -E, Escape Sequences; FreeBSD jexec(8) OPTIONS
Linux, FreeBSDNFS restrictionzlogin fails if its open files or any part of its address space, including the executable or shared libraries, are on NFS. The other pages do not mention this.
Source: Solnix zlogin(1) NOTES

Everyday tasks

TaskSolnixLinuxFreeBSD
get a shell in a zone, jail or containerzlogin zonenamensenter -t PID -a, or machinectl shell NAMEjexec jail
run one command insidezlogin zonename utility [argument]...nsenter -t PID -a program [arguments]jexec jail command ...
run as a named userzlogin -l username zonenamemachinectl --uid=user shell NAMEjexec -U username jail
attach to the consolezlogin -C zonename——
run in a clean environment——jexec -l jail

Standards

  • POSIX: zlogin is not a POSIX.1-2024 utility.
  • Solnix: Interface Stability: Evolving.

Writing portable scripts

  • There is no common syntax. Branch on which of zlogin, jexec, nsenter or machinectl exists, and do not pass the same flags to each, since -n, -C and -l mean different things.
  • Use the exit status only from non-interactive zlogin (with a utility). In interactive and console modes zlogin does not return the inner exit status.

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.