NAME
chroot
—
execute with alternate filesystem
root
SYNOPSIS
chroot |
[--userspec =user[:group]]
[-u ser]
[-g roup]
[-G
roup[,group]…]
root [program
[argument]…] |
chroot |
--skip-chdir
[--userspec =user[:group]]
[-u ser]
[-g roup]
[-G
roup[,group]…]
/ [program
[argument]…] |
DESCRIPTION
Sets the filesystem root to root, alters
credentials as specified, then executes program
arguments (SHELL
-i
if not specified).
User and group names are first sought in the initial root, then overriden from the alternate root. Numeric IDs are used verbatim.
OPTIONS
--userspec
=user[:group]- Become user and group (or the user's primary group if omitted).
-u
user- Become user.
-g
group- Become group.
-G
,--groups
=group[,group]…- Set the supplementary group list to groups.
--skip-chdir
- Don't move to the root after switching root directories. Only valid when switching to the current root directory.
ENVIRONMENT
PATH
- In which program is searched when requested, confer execvp(3).
SHELL
- The shell to execute for an interactive session instead of the default /bin/sh.
EXIT STATUS
- 127
- program wasn't found.
- 126
- program exists, but couldn't be executed for a different reason.
- 125
- an error occurred in
chroot
. - All others
- returned by program.
SEE ALSO
STANDARDS
Conforms to X/Open Portability Guide Issue 2 (“XPG2”) (CB-UNIX), compatible with 4.3BSD-Reno. Long options and name resolution scheme compatible with the GNU system. Short options compatible with NetBSD 1.4.
HISTORY
The chroot
() system call appeared in
Version 7 AT&T UNIX as part of
chdir(2) — "change default directory"
— noting it to not be unlike that of today:
chroot
first appeared in CB-UNIX at or
before version 2.1 as
chroot(1M) — "change root directory for a
command":
CB-UNIX was, among others, the basis for AT&T System III UNIX, where it first saw light outside of AT&T with an incorrect
chroot rootdir command arg
...
chroot(8) appears in 4.3BSD-Reno, as
SHELL
(/bin/sh) -i
default.
A specification for a CB-UNIX-style(? possibly, no digital copies
seem to be extant) chroot
appears in X/Open
Portability Guide Issue 2
(“XPG2”), but was removed in X/Open
Portability Guide Issue 4 (“XPG4”).