16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examples<br />

The directory path name is always relative to the current root. If a nested chroot<br />

command is in effect, the directory path name is still relative to the current (new)<br />

root of the running process.<br />

In order for your process to operate properly after the chroot is issued, you need to<br />

have in your new root all the files that your program depends on. For example, if<br />

your new root is /tmp and you issue an ls, you will get a not found error. To use ls<br />

with /tmp as your new root, you will need a /tmp/bin with ls in it before you issue<br />

the chroot command.<br />

In addition, utilities that depend on locale-sensitive files (/usr/lib/nis/*) may be<br />

unsuccessful if these files are not in the new root file system.<br />

After chroot is issued, your current working directory is the new root (directory),<br />

chroot does not change environment variables.<br />

directory<br />

Specifies the new root directory<br />

command<br />

Specifies a command to run with the chroot command<br />

1. To run the ls command with the /tmp directory as the root file system, enter:<br />

mkdir /tmp/bin<br />

cp /bin/ls /tmp/bin<br />

chroot /tmp ls<br />

2. To run a child shell with another file system as the root file system (assuming<br />

that /tmp is the mount point of a file system), enter:<br />

mkdir /tmp/bin<br />

cp /bin/sh /tmp/bin<br />

chroot /tmp sh or chroot /tmp /bin/sh<br />

This makes the directory name / (slash) refer to the /tmp for the duration of the<br />

/bin/sh command. It also makes the original root file system inaccessible. The<br />

file system on the /tmp file must contain the standard directories of a root file<br />

system.<br />

Running the /bin/sh command creates a child shell that runs as a separate<br />

process from your original shell. Press the END OF FILE (Crtl-D) key sequence<br />

or type exit to end the child shell and go back to where you were in the original<br />

shell. This restores the environment of the original shell, including the meanings<br />

of the . (current directory) and the / (root directory).<br />

3. To create a file relative to the original root, not the new one, enter:<br />

chroot Directory <strong>Command</strong> > file<br />

For example, chroot /tmp ls > /bin/file will create the file in /bin/file.<br />

Note: Redirection is handled by the current shell before chroot is executed.<br />

4. To create a file relative to the new root, enter:<br />

chroot Directory ’<strong>Command</strong> > file’<br />

For example, chroot /tmp ’ls > /bin/file’ will create the file in /tmp/bin/file.<br />

5. Examples of how the current root changes:<br />

chroot<br />

Chapter 2. Shell command descriptions 131

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!