CHROOT(8) Maintenance Commands CHROOT(8)

chroot - change system's root directory and execute a command there

chroot newroot [command]

The chroot command calls chroot(2) to change the system's root (/) directory to newroot and exec(3) to execute command — and any of its child processes — there.

The directory to switch the command's system root to.
The command to execute, relative to NEWROOT.

Please, take note that redirecting the output of command to a file will create it relative to the original root, not in the new one.

For instance, let's redirect command's standard output to a file called "x" at the /tmp directory:

# chroot newroot command >/tmp/x

This will create x relative to the original root directory, not in newroot.

If you need to redirect the output inside the newroot, you will need to quote the actual command and prefix it with sh(1) followed by the "-c" option, like this:

# chroot newroot /bin/sh -c 'command >/tmp/x'

cd(1), chroot(2), exec(3)

04/29/23 Heirloom Toolchest