Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ chroot(1) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc

cpp

sh

chdir

chroot

chroot

PURPOSE

     Changes the root directory of a command.

SYNOPSIS
     chroot directory command

DESCRIPTION

     Warning:  If special files in the new root have different
     major and minor device numbers than they have in the real
     root, it is possible to overwrite the file system.

     The chroot command  can be used only by  a user operating
     with superuser authority (see  "su").  If you have super-
     user  authority,  the  chroot command  changes  the  root
     directory  to  the  specified  directory  when  executing
     command.  The first / (slash) in any path name changes to
     directory for the specified command  and any of its chil-
     dren.

     Notice that:

         chroot directory  command  > file

     creates the file. relative to  the original root, not the
     new one.

     The directory path name is always relative to the current
     root.  Even if a chroot  is in effect, directory is rela-
     tive to the current root of the running process.

     Several programs  may not  operate properly  after chroot
     has been run.   For example, the command ls  -l will fail
     to give user and group names if the current root location
     makes /etc/passwd  beyond reach.  In  addition, utilities
     that  depend on  description files  produced by  the ctab
     command (see page 247) may fail altogether if these files
     are also  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.

EXAMPLES

     1.  To run  a subshell  with another  file system  as the
         root:

           chroot  /diskette0  /bin/sh

         This makes  the directory name /  refer to /diskette0
         for  the duration  of the  command /bin/sh.   It also
         makes  the original  root  file system  inaccessible.
         The  file  system  on  /diskette0  must  contain  the

         standard directories of a  root file system.  In par-
         ticular, the shell will look for commands in /bin and
         /usr/bin on the /diskette0 file system.

         Running the command /bin/sh creates a subshell, which
         runs as a separate  process from your original shell.
         Press END OF FILE (Ctrl-D) 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 (/).
     2.  To run a command in another root file system and save
         the output:

           chroot  /diskette0  /bin/cc  -E  /u/bob/prog.c  >prep.out

         This  runs the  /bin/cc command  with /  referring to
         /diskette0.   It   saves  the  output  in   the  file
         "prep.out",  which  is  in  the  original  root  file
         system.

         This runs the C  language preprocessor ("/bin/cc -E")
         on   the   file  "/diskette0/u/bob/prog.c",   reading
         #include   files  from   /diskette0/usr/include,  and
         putting the  preprocessed text  in "prep.out"  on the
         primary root file system.

RELATED INFORMATION

     The following commands:  "cc,"  "cpp," and "sh."

     The chdir and chroot system calls in AIX Operating System
     Technical Reference.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026