各种Linux版本如何进入单用户
1.Ubuntu
菜单界面——>选recovery模式 按e 编辑 ro 哪一行变为
rw single init=/bin/bash
删除后面的recoverymode ctrl + X 进入单用户
cd /etc chmod 0440 sodoers passwd root
改完重启即可
2.centos
开机时按任意键——>e——选Kenle按e——在quiet后面加个‘1’或者‘single’ enter——>B 直接就进入了单用户模式 最新的centos7版本——>按e——>进入下图页面
——>在UTF8后面加上 init=/bin/bash,将ro改为rw,并且删除后面直至quit中间的字符,按ctrl+x即可进入单用户
3.debian
跟Ubuntu一样(rw init=/bin/bash 去除quiet字符)
最后别忘了退出单用户并且重启命令:
exec /sbin/init
但是并不会这样顺利
报错一:明明已经修改了root密码,显示successfully,进系统用新密码登录还是会显示login failed
这个时候只需要在单用户改密码前加上如下命令即可生效:
touch /.autorelabel //SELinux (selinux开启后生效)
报错二:改密码时直接报错:passwd: Authentication token manipulation error
原因:和之前的安全加固有关系,通过手工修改/etc/passwd等两个文件的属性即可成功修改密码 备注:chattr 改变文件属性。 i:即Immutable,系统不允许对这个文件进行任何的修改。如果目录具有这个属性,那么任何的进程只能修改目录之下的文件,不允许建立和删除文件
解决问题的方法如下:先修改文件属性为可修改,再改回来,具体如下
[root@linux1 /]# passwd oracle Changing password for user oracle. New password: Retype new password: passwd: Authentication token manipulation error [root@linux1 /]# [root@linux1 /]# [root@linux1 /]# ls -l /etc/passwd -rw-r--r-- 1 root root 1831 May 30 14:24 /etc/passwd [root@linux1 /]# ls -l /etc/shadow -rw-r--r-- 1 root root 1430 May 30 15:52 /etc/shadow [root@linux1 /]# chattr -i /etc/passwd [root@linux1 /]# chattr -i /etc/shadow [root@linux1 /]# root@linux1 /]# [root@linux1 /]# passwd oracle Changing password for user oracle. New password: Retype new password: passwd: all authentication tokens updated successfully. [root@linux1 /]# [root@linux1 /]# [root@linux1 /]# chattr +i /etc/shadow [root@linux1 /]# chattr +i /etc/passwd [root@linux1 /]#
好啦,有了上面的操作,麻麻再也不怕忘记root密码了
注:以上都是针对没有设置禁止进单用户改密码的系统哦,并且,目前较为常见的报错就是以上两种,如还有其他报错和解决办法,欢迎各位小伙伴们一起分享到我的邮箱!