有效處理Linux系統下root用戶執行passwd修改密碼時報錯Authentication token manipulation error

今天準備修改Linux系統的root用戶密碼時,執行passwd root,出現瞭如下狀況,修改密碼失敗:node

# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: Authentication token manipulation error

到網上搜了下,有的說是由於inodes用完,也就是根分區滿了引發的,但執行df -i並不是找個緣由:python

# 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選項,查詢結果以下:linux

# 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修改密碼code

# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

修改完密碼後,爲了安全起見,能夠執行chattr +i爲用戶密碼系統文件增長i權限blog

# chattr +i /etc/passwd
# chattr +i /etc/shadow
# lsattr /etc/passwd
----i--------e- /etc/passwd
# lsattr /etc/shadow
----i--------e- /etc/shadow

福利:豆花同窗爲你們精心整理了一份關於linux和python的學習資料大合集!有須要的小夥伴們,關注豆花我的公衆號:python頭條!回覆關鍵詞「資料合集」便可免費領取!token

相關文章
相關標籤/搜索