Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 bash 脚本中检查用户密码是否正确?如果是这样,请告诉我如何。谢谢
这对我有用:
#ensure sudo isn't saving a recent password sudo -k #prime it echo $ROOTPASSWORD | sudo -S echo hello &> /dev/null #test it if ! [ "$(sudo -n echo hello 2>&1)" == "hello" ]; then echo "Incorrect password was entered" fi