chroot
Quick Reference
Command Name:
chroot
Category:
system management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
System isolation
Create isolated environments for testing or security
- 2
System recovery
Access and repair systems from recovery environments
- 3
Containerization
Create container-like environments for applications
- 4
Security hardening
Limit application access to specific directories
Syntax
chroot [OPTION] NEWROOT [COMMAND [ARG]...]
Options
| Option | Description |
|---|---|
--groups=G_LIST |
Specify supplementary groups as g1,g2,...,gN |
--userspec=USER:GROUP |
Specify user and group (ID or name) to use |
--skip-chdir |
Don't change working directory to '/' |
--help |
Display help message and exit |
--version |
Display version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the chroot command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
sudo chroot /mnt/system /bin/bash
sudo chroot /mnt/system ls -la /
sudo chroot /mnt/system /usr/bin/dpkg -l
sudo chroot --userspec=john:users /mnt/system /bin/bash