Chinaunix首页 | 论坛 | 博客

分类:

2009-01-28 14:51:11

`chroot' runs a command with a specified root directory.  On many
systems, only the super-user can do this.  Synopses:
‘chroot’使用一个指定的根目录运行命令,在大多数系统上,仅限于超级用户可以做这个动作。
 
     chroot NEWROOT [COMMAND [ARGS]...]
     chroot OPTION
 
   Ordinarily, file names are looked up starting at the root of the
directory structure, i.e., `/'.  `chroot' changes the root to the
directory NEWROOT (which must exist) and then runs COMMAND with
optional ARGS.  If COMMAND is not specified, the default is the value
of the `SHELL' environment variable or `/bin/sh' if not set, invoked
with the `-i' option.  COMMAND must not be a special built-in utility
(*note Special built-in utilities::).

通常情况下,搜索文件名开始于根目录结构。比如‘/’。‘chroot’命令更改root的路径到新的root的路径。并根据ARGS的选项运行命令。如果没有指定命令,则根据`-i'选项,采取默认的‘shell’的环境变量值或者是没有设置的'/bin/sh',命令绝不能是一个特殊的内置的功能。
 
   The only options are `--help' and `--version'.  *Note Common
options::.  Options must precede operands.
 
   Here are a few tips to help avoid common problems in using chroot.
To start with a simple example, make COMMAND refer to a statically
linked binary.  If you were to use a dynamically linked executable, then
you'd have to arrange to have the shared libraries in the right place
under your new root directory.
   对帮助信息有一些提示,避免在chroot中使用公用程序。举一个简单的例子,让命令指向一个二进制静态链接。如果你执行一个动态链接执行档,那么你必须在你的新root目录下整理共享库到合适的目录。
 
   For example, if you create a statically linked `ls' executable, and
put it in `/tmp/empty', you can run this command as root:

   比如说,你创建了一个静态链接`ls'执行档,并放入`/tmp/empty'目录中,你可以作为root用户执行这个命令。
 
     $ chroot /tmp/empty /ls -Rl /
 
   Then you'll see output like this:
 
     /:
     total 1023
     -rwxr-xr-x 1 0 0 1041745 Aug 16 11:17 ls
 
   If you want to use a dynamically linked executable, say `bash', then
first run `ldd bash' to see what shared objects it needs.  Then, in
addition to copying the actual binary, also copy the listed files to
the required positions under your intended new root directory.
Finally, if the executable requires any other files (e.g., data, state,
device files), copy them into place, too.
   如果你想使用动态链接执行档,告诉‘bash’,首先运行‘ldd bash’,看看需要哪一些共享对象。
除了复制实际的二进制文件,也复制文件列表到你指定的新root的目录下。

   最后,如果执行档要求其他一些文档,也把这些文档复制到正确的地方。
   Exit status:
 
     1   if `chroot' itself fails
     126 if COMMAND is found but cannot be invoked
     127 if COMMAND cannot be found
     the exit status of COMMAND otherwise
 
阅读(5682) | 评论(0) | 转发(0) |
0

上一篇:什么是MBR

下一篇:Linux开机启动程序详解

给主人留下些什么吧!~~