1.\" $OpenBSD: chroot.8,v 1.14 2010/07/08 06:52:30 jmc Exp $ 2.\" 3.\" Copyright (c) 1988, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)chroot.8 8.1 (Berkeley) 6/9/93 31.\" 32.Dd $Mdocdate: July 8 2010 $ 33.Dt CHROOT 8 34.Os 35.Sh NAME 36.Nm chroot 37.Nd change root directory 38.Sh SYNOPSIS 39.Nm chroot 40.Op Fl g Ar group,group,... 41.Op Fl u Ar user 42.Ar newroot 43.Op Ar command 44.Sh DESCRIPTION 45The 46.Nm 47command changes its root directory to the supplied directory 48.Ar newroot 49and executes 50.Ar command , 51if supplied, or an interactive copy of the user's shell. 52.Pp 53The 54.Nm 55command is restricted to the superuser. 56.Pp 57The options are as follows: 58.Bl -tag -width Ds 59.It Fl g Ar group,group,... 60Override the primary and supplemental group IDs. 61The primary group ID is set to the first group in the list. 62Any remaining groups are placed in the supplemental group ID vector. 63Each group listed must exist in the 64.Xr group 5 65databases. 66.It Fl u Ar user 67Set user ID to 68.Ar user 69(which must exist in the 70.Xr passwd 5 71database). 72The primary and supplemental group IDs will be set based on the user's 73entries in the 74.Xr passwd 5 75and 76.Xr group 5 77databases unless overridden by the 78.Fl g 79option. 80.El 81.Sh ENVIRONMENT 82.Bl -tag -width SHELL 83.It Ev SHELL 84If set, 85the string specified by 86.Ev SHELL 87is interpreted as the name of 88the shell to execute. 89If the variable 90.Ev SHELL 91is not set, 92.Pa /bin/sh 93is used. 94.El 95.Sh SEE ALSO 96.Xr ldd 1 , 97.Xr group 5 , 98.Xr passwd 5 , 99.Xr environ 7 100.Sh HISTORY 101The 102.Nm 103utility first appeared in 104.Bx 4.3 Reno . 105.Sh CAVEATS 106.Nm 107should never be installed setuid root, as it would then be possible 108to exploit the program to gain root privileges. 109