24.5.3 Using a Chroot Jail

To run a command in a chroot jail in an existing directory (chroot_jail), use the following command:

# chroot chroot_jail command

If you do not specify a command argument, chroot runs the value of the SHELL environment variable or /bin/sh if SHELL is not set.

For example, to run /bin/bash in a chroot jail (having previously set it up as described in Section 24.5.2, “Creating a Chroot Jail”):

# chroot /home/oracle/jail
bash-4.1# pwd
bash-4.1# ls
bash: ls: command not found
bash-4.1# exit

You can run built-in shell commands such as pwd in this shell, but not other commands unless you have copied their binaries and any required shared libraries to the chroot jail.

For more information, see the chroot(1) manual page.