---
name: "chroot"
section: "8"
platform: "macos"
package: "shell_cmds"
version: "329"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/chroot/8"
---

# chroot(8)

change root directory

## NAME

**chroot** – change root directory

## SYNOPSIS

**chroot** \[**-G** *group*\[**,***group* *...*\]\] \[**-g** *group*\] \[**-u** *user*\] *newroot* \[*command* \[*arg* *...*\]\]

## DESCRIPTION

The **chroot** utility changes its current and root directories to the supplied directory *newroot* and then exec's *command* with provided arguments, if supplied, or an interactive copy of the user's login shell.

The options are as follows:

- **-G** *group*\[**,***group* *...*\]

  Run the command with the permissions of the specified groups.

- **-g** *group*

  Run the command with the permissions of the specified *group*.

- **-u** *user*

  Run the command as the *user*.

## ENVIRONMENT

The following environment variable is referenced by **chroot**:

- SHELL

  If set, the string specified by SHELL is interpreted as the name of the shell to exec. If the variable SHELL is not set, */bin/sh* is used.

## EXAMPLES

- **Example** **1:** Chrooting into a New Root Directory

  The following command opens the [csh(1)](/csh/1.md) shell after chrooting to the standard root directory.

  ```
  # chroot / /bin/csh
  ```

- **Example** **2:** Execution of a Command with a Changed Root Directory

  The following command changes a root directory with **chroot** and then runs [ls(1)](/ls/1.md) to list the contents of */sbin*.

  ```
  # chroot /tmp/testroot ls /sbin
  ```

## SEE ALSO

[chdir(2)](/chdir/2.md), [chroot(2)](/chroot/2.md), [setgid(2)](/setgid/2.md), [setgroups(2)](/setgroups/2.md), [setuid(2)](/setuid/2.md), [getgrnam(3)](/getgrnam/3.md), [environ(7)](/environ/7.md)

## HISTORY

The **chroot** utility first appeared in AT&T System III UNIX and 4.3BSD-Reno.
