I tried to explain what "chrooting" is to a group of starting Linux gurus. It seemed rather difficult to explain. So, maybe an illustrated article will explain what chroot is.
From chroot's manpage:
chroot - run command or interactive shell with special root directoryAnd in my own words:
chroot starts a process in a directory which looks like the root directory to that process.Here is an example of how chroot can be used to reset a root password on an existing system. (Even works when the bootloader (grub) has a password set.)
- Insert a linux boot or install CD/DVD and make the computer boot from that cd.
- When the CD boots and starts the installer, hit [CTRL]+[ALT]+[F2] to go to a shell.
- Now that you have a shell available, you must mount the / (maybe /usr too) directory. Mostly you don't know what directory was the / directory, so you will end up mounting an unmounting a few times.
mkdir /mnt/a && mount /dev/sda5 /mnt/a && mount /dev/sda3 /mnt/a/usr - When you have the required mountpoints mounted, execute a chroot, like this:
chroot /mnt/a /bin/sh - Now you can execute passwd, which is actually /mnt/a/usr/bin/passwd. The password will be updated in /etc/shadow, which is actually /mnt/a/etc/shadow

本文介绍如何利用chroot技术在Linux系统中重置忘记的root密码。通过引导进入安装介质并创建临时文件系统,之后通过chroot切换根目录环境来修改密码。
3262

被折叠的 条评论
为什么被折叠?



