红联Linux门户
Linux帮助

Linux下root修改密码报错解决方案

发布时间:2017-12-09 09:16:41来源:红联作者:Ronny
今天准备修改Linux系统的root用户密码时,执行passwd root,出现了以下情况,修改密码失败:

# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: Authentication token manipulation error
到网上搜了下,有的说是因为inodes用完,也就是根分区满了引起的,但执行df -i并非找个原因:

# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 6406144 58534 6347610 1% /
tmpfs 8242797 2 8242795 1% /dev/shm
继续找答案,按照网上的案例检查用户密码相关的系统文件/etc/passwd和/etc/shadow,发现这两个文件权限有i选项,查询结果如下:

# lsattr /etc/passwd
---i-----e- /etc/passwd
# lsattr /etc/shadow
---i-----e- /etc/shadow
备注:在Linux系统里,文件有i选项则表示不得对其做任何的修改,这也就导致了修改密码失败。

要解决该问题,则需要执行chattr -i命令,将以上两个文件i权限撤销掉

# chattr -i /etc/passwd
# chattr -i /etc/shadow
# lsattr /etc/passwd
---------e- /etc/passwd
# lsattr /etc/shadow
---------e- /etc/shadow
然后再执行passwd修改密码,

# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
修改完密码后,为了安全起见,可以执行chattr +i为用户密码系统文件增加i权限

# chattr +i /etc/passwd
# chattr +i /etc/shadow
# lsattr /etc/passwd
---i-----e- /etc/passwd
# lsattr /etc/shadow
---i-----e- /etc/shadow
本文转载自:http://www.linuxprobe.com/linux-root-passwd.html

免费提供最新Linux技术教程书籍,为开源技术爱好者努力做得更多更好,开源站点:http://www.linuxprobe.com/
文章评论

共有 1 条评论

  1. Ronny 于 2017-12-09 09:16:55发表:

    Linux下root修改密码报错解决方案