忘记 root 密码修改 /etc/shadow 重置密码
2024-03-18 本文已影响0人
河码匠
field=$(awk -F ':' '/^root/{print $2}' /etc/shadow)
password=$(openssl passwd -1 123456)
sed -i '/^root/s%'$field'%'$password'%' /etc/shadow
field=$(awk -F ':' '/^root/{print $2}' /etc/shadow)
password=$(openssl passwd -1 123456)
sed -i '/^root/s%'$field'%'$password'%' /etc/shadow