The chroot command in Linux/Unix systems is used to change the root directory. Every process/command in Linux/Unix-like systems has a current working directory called the root directory. It changes the root directory of the currently running process and its child processes.
Processes/commands running in such a modified environment cannot access files outside the root directory. This modified environment is called a "chroot jail" or "jail directory" . Certain root users and privileged processes are allowed to use the chroot command.
The "chroot" command is very useful:
-
Create a test environment.
-
Recover system or password.
-
Reinstall the bootloader.
syntax:
chroot /path/to/new/root command
or
chroot /path/to/new/root/path/to/serverchroot /path/to/new/root /path/to/server
or
chroot [选项] /path/to/new/root /path/to/serverchroot [options] /path/to/new/root /path/to/server
Options:
-
–userspec=USER:GROUP : This option describes the