今天在配置NIS的时候,在客户端上把passwd文件给重命名为passwd.bak了,当时并没有显示什么不正常,但重启机器后就无法启动了!

启动就会显示:

General error mounting filesystems.
A maintenance shell will now be started.
Control-D will terminate this shell and reboot the system.
/dev/sda1:clean
sulogin:cannot open password database!
 
单用户模式也无法进入!
 

 
解决办法:
1、grub引导时使用init=/bin/sh,启动(或者从光盘启动rescue模式)
2、重新挂载/,使其可读写:mount -o remount,rw /dev/sda1 /
3、进入/etc目录,把passwd文件恢复(比如将.bak文件还原,从passwd-文件恢复,从/var/backups目录中恢复)
4、修改passwd文件的权限为系统相应的权限:644
5、查看/etc/nsswitch.conf文件中的passwd查找顺序是否正确,应该是compat或者files
6、使用getent passwd命令检查是否能够得到数据。
 
重新启动,应该能够恢复正常
 
PS:如果group文件,或者shadow文件出现类似的问题,也是此法