首頁  >  文章  >  系統教程  >  Linux下root修改密碼錯誤解決方案

Linux下root修改密碼錯誤解決方案

WBOY
WBOY轉載
2024-02-21 10:50:03698瀏覽

Linux下root修改密碼錯誤解決方案

今天準備修改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

以上是Linux下root修改密碼錯誤解決方案的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:linuxprobe.com。如有侵權,請聯絡admin@php.cn刪除