在linux中如何修改密碼
當你還記得root密碼
可以去使用root賬號直接修改
在root權限下你無需知道原密碼,root可以強制修改一般用戶密碼
操作為:
su root
passwd user
Changing password for user root.
New password:
Retype new password:
passwd: Authentication token manipulation error

當你忘了root密碼
方法一:1.重啟系統使用 ↑ 和 ↓ 將選擇行設定為第一行(背景高亮即為選中),按下鍵盤上的 e ,進入編輯模式

將游標一直移動到 LANG=en_US.UTF-8 后面,空格,再追加 init=/bin/sh ,這里特別注意,需要寫在UTF-8后,保持在同一行,并注意空格,由于螢屏太小,會自動添加\換行,這個是正常的,

按下ctrl+x執行修改進入引導界面
掛載根目錄
mount -o remount, rw /
passwd root
如果想要看到自己的密碼可以輸入:echo redhat |passwd --stdin root(或者直接打passwd)
最后結果如圖

退出操作界面之前記得更新系統資訊(如果開了selinux)
命令是:touch /.authorelabel
最后重啟系統
```c
exec /sbin/init
或
exec /sbin/reboot
方法二:還是進入幫助界面

在initrd 前輸入rd.break
ctrl+x
mount |grep sysroot //查看sysroot權限
mount -o remount,rw /sysroot/ //修改ro權限為rw
mount |grep sysroot //再次查看
chroot /sysroot //修改權限
echo redhat |passwd --stdin root(直接打passwd也可以)
touch /.autorelabel 多載修改
exit
reboot
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/246936.html
標籤:其他
