HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

chroot — Run command or interactive shell with special root directory. More information: <https://www.gnu.org

Submitted by: @import:tldr-pages··
0
Viewed 0 times
shellcommandruncliwithinteractivechroot

Problem

How to use the chroot command: Run command or interactive shell with special root directory. More information: <https://www.gnu.org/software/coreutils/manual/html_node/chroot-invocation.html>.

Solution

chroot — Run command or interactive shell with special root directory. More information: <https://www.gnu.org/software/coreutils/manual/html_node/chroot-invocation.html>.

Run $SHELL in the new root directory:
sudo chroot {{path/to/new_root}}


Run command as new root directory:
sudo chroot {{path/to/new_root}} {{command}}


Use a specific user and group:
sudo chroot --userspec {{username_or_id}}:{{group_name_or_id}} {{path/to/new_root}}

Code Snippets

Run `$SHELL` in the new root directory

sudo chroot {{path/to/new_root}}

Run command as new root directory

sudo chroot {{path/to/new_root}} {{command}}

Use a specific user and group

sudo chroot --userspec {{username_or_id}}:{{group_name_or_id}} {{path/to/new_root}}

Context

tldr-pages: common/chroot

Revisions (0)

No revisions yet.