JEXEC(8)
π JEXEC(8) π
hey bestie, welcome to JEXEC(8) from the System Manager's Manual β this one is literally about running a command inside a jail that's already up and running. no cap, it's giving "let me just pop into this jail real quick" energy π«Ά
β¨ NAME β¨
jexec β execute a command inside an existing jail, periodt π
π¦ SYNOPSIS π¦
jexec [-l] [-d working-directory] [-u username | -U username] jail
[command ...]
πΈ DESCRIPTION πΈ
okay so the jexec utility executes command inside the jail identified by its jid or name. if command is not specified then the user's shell is used. iconic, honestly β¨
the following options are available:
π OPTIONS π
-d working-directoryβ the working directory for running commands inside the jail. the default is the jail root directory. very "set the vibe before you walk in" π-lβ execute in a clean environment. the environment is discarded except forHOME,SHELL,TERM,USER, and anything from the login class capability database for the user.PATHis set to"/bin:/usr/bin". if a user is specified (via-uor-U), and absent the-doption, commands are run from that (possibly jailed) user's directory. clean slate, no baggage, we love to see it π§-u usernameβ the user name from host environment as whom the command should run. this is the default. host-side user, classic behavior π-U usernameβ the user name from jailed environment as whom the command should run. jailed-side user, for when you're being extra specific π₯
π EXAMPLES π
π Example 1: Open a shell in a jail
the following command specifies a jail by its name and utilizes the current user's shell:
# jexec name
it is also possible to specify a jail by its jid:
# jexec JID
π Example 2: Run a single command without opening a shell
the following command runs uname -a in a jail called "name". since a command is specified explicitly, jexec does not spawn an interactive shell. instead, jexec executes the specified command directly. lowkey efficient fr fr β
# jexec name uname -a
π¦ Example 3: Open a shell in a jail with a clean environment
the following command opens a sh(1) shell in a jail with a clean environment:
# jexec -l name sh
π Example 4: Open a shell in a jail with the login command
the following command utilizes login(1) to access the jail, submitting an audit record, and displaying the user's last login, system copyright, and motd(5) message:
# jexec -l name login -f root
π SEE ALSO π
β HISTORY β
the jexec utility was added in FreeBSD 5.1. vintage but still slaying π
π BUGS π
if the jail is not identified by jid there is a possible race in between the lookup of the jail and executing the command inside the jail. giving a jid has a similar race as another process can stop the jail and start another one after the user looked up the jid.
heads up bestie β race conditions are not the cute kind of drama π keep this in mind.
mwah π this page is brought to you by Debian, dated March 5, 2025, and lives in the System Manager's Manual β catch u later, bestie π«Ά
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms