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.
- NEWROOT
- The directory to switch the command's system root to.
- COMMAND
- 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)