我已经建立了完整的可运行的debootstrap-ed臂chroot环境。我可以chroot
在其中运行命令等。
我正在制作一个可以自定义chroot env的脚本,但是我为此感到困惑。
例如:
chroot $target_dir echo this is a test > /tmp/test
谁能向我解释,为什么在此示例中,我将输出写在主机环境中而不是chroot中?
只是说,我可以执行
echo this is a test > $target_dir/tmp/test
但我想知道为什么chroot执行“失败”
编辑:
这也适用:
chroot $target_dir /bin/bash -c "echo test > /tmp/test"
运行时:
chroot $target_dir echo this is a test > /tmp/test
在> /tmp/test
发生“为” chroot命令,就像如果你这样写:
> /tmp/test chroot $target_dir echo this is a test
如果您希望重定向发生在chroot命令内部,则一种方法是:
chroot $target_dir sh -c 'echo this is a test > /tmp/test'
...放入sh
chroot中,让echo可以看到正确的重定向目录。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句