Linux common commands-83: chroot

The chroot command is used to change the root directory. The default root directory of the system is / . After a running process is chroot , its root directory will be explicitly mapped to a specified directory, and it will not be able to access files outside the specified directory. Executing chroot requires root privileges.

Syntax format: chroot [parameter]

Common parameters:

Example

 # 改变根目录为/mnt/test sudo chroot /mnt/test # 改变根目录并执行相应命令,前提是在新目录下有这些命令sudo chroot /mnt/test /bin/bash # 从新的根目录中退出exit

This article is reprinted from https://xugaoxiang.com/2022/07/06/linux-cmds-83-chroot/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment