Changes the root directory of a command.
chroot Directory Command
Attention: If special files in the new root directory have different major and minor device numbers than the real root directory, it is possible to overwrite the file system.
The chroot command can be used only by a user operating with root user authority. If you have root user authority, the chroot command changes the root directory to the directory specified by the Directory parameter when performing the Command. The first / (slash) in any path name changes to Directory for the specified Command and any of its children.
The Directory path name is always relative to the current root. Even if the chroot command is in effect, the Directory path name is relative to the current root of the running process.
A majority of programs may not operate properly after the chroot command runs. For example, the commands that use the shared libraries are unsuccessful if the shared libraries are not in the new root file system. The most commonly used shared library is the /usr/ccs/lib/libc.a library.
The ls -l command is unsuccessful in giving user and group names if the current root location makes the /etc/passwd file beyond reach. In addition, utilities that depend on localized files (/usr/lib/nls/*) may also be unsuccessful if these files are not in the new root file system. It is your responsibility to ensure that all vital data files are present in the new root file system and that the path names accessing such files are changed as necessary.
Command | Specifies a command to run with the chroot command. |
Directory | Specifies the new root directory. |
Attention: The commands in the following examples may depend on shared libraries. Ensure that the shared libraries are in the new root file system before you run the chroot command.
mkdir /usr/bin/lib cp /usr/ccs/lib/libc.a /usr/bin/lib chroot /usr/bin pwd
chroot /var/tmp /usr/bin/kshThis makes the directory name / (slash) refer to the /var/tmp for the duration of the /usr/bin/ksh command. It also makes the original root file system inaccessible. The file system on the /var/tmp file must contain the standard directories of a root file system. In particular, the shell looks for commands in the /bin and /usr/bin files on the /var/tmp file system.
Running the /usr/bin/ksh command creates a subshell that runs as a separate process from your original shell. Press the END OF FILE (Ctrl-d) key sequence to end the subshell and go back to where you were in the original shell. This restores the environment of the original shell, including the meanings of the . (current directory) and the / (root directory).
chroot directory Command > file
The chdir subroutine, chroot subroutine.
The File Systems Overview for System Management in AIX Version 4.3 System Management Guide: Operating System and Devices explains file system types, management, structure, and maintenance.