Change the root directory for a process and its children.
high risk
findmnt -R /mntVerify the mounts of the target tree before chrooting.chroot changes the apparent root directory for a process, isolating it from the rest of the filesystem. Used for system rescue (booting into a broken system's filesystem), building packages in clean environments, and as the foundation for containers.
mount /dev/sda1 /mnt && chroot /mnt /bin/bashChroot into a mounted system for rescue · explain & risk-check →chroot /mnt /usr/bin/passwd rootReset root password on mounted system · explain & risk-check →mount --bind /dev /mnt/dev && mount --bind /proc /mnt/proc && chroot /mntFull rescue chroot with devices and proc · explain & risk-check →For a full rescue chroot, always bind-mount /dev, /proc, /sys, and /run before chrooting — without them, systemd, udev, and many tools will fail with cryptic errors.
Reference text is hand-written and may be incomplete — check man chroot for your version. Test destructive commands on a non-production system first.