SHELL
If set, the string specified by SHELL is interpreted as the name of the shell to exec. If the variable SHELL is not set, /bin/sh is used.
Change root directory
chroot [-G
group
[,group ...]]
[-g
group]
[-u
user]
[-n]
newroot
[command
[arg ...]]
The chroot utility changes its current and root directories to the supplied directory newroot and then exec's command with provided arguments, if supplied, or an interactive copy of the user's login shell.
The options are as follows:
-G group[,group ...]Run the command with the specified groups as supplementary groups.
-g group
Run the command with the specified group as the real, effective and saved groups.
-u user
Run the command with the specified user as the real, effective and saved users.
-n
Use the PROC_NO_NEW_PRIVS_CTL procctl(2) command before chrooting, effectively disabling SUID/SGID bits for the calling process and its descendants. If security.bsd.unprivileged_chroot sysctl is set to 1, it will make it possible to chroot without superuser privileges.
The following environment variable is referenced by chroot:
SHELL
If set, the string specified by SHELL is interpreted as the name of the shell to exec. If the variable SHELL is not set, /bin/sh is used.
Example 1: Chrooting into a New Root DirectoryThe following command opens the csh(1) shell after chrooting to the standard root directory.
# chroot / /bin/csh
Example 2: Execution of a Command with a Changed Root DirectoryThe following command changes a root directory with chroot and then runs ls(1) to list the contents of /sbin.
# chroot /tmp/testroot ls /sbin
87 releases since FreeBSD 2.0.5-RELEASE; the text changed 48 times.
-g since FreeBSD 13.0-RELEASE;
-n since FreeBSD 13.1-RELEASE;
-u since FreeBSD 13.0-RELEASE.