⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setnew-passwd.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash#  setnew-password.sh: For demonstration purposes only.#                      Not a good idea to actually run this script.#  This script must be run as root.ROOT_UID=0         # Root has $UID 0.E_WRONG_USER=65    # Not root?E_NOSUCHUSER=70SUCCESS=0if [ "$UID" -ne "$ROOT_UID" ]then  echo; echo "Only root can run this script."; echo  exit $E_WRONG_USERelse  echo  echo "You should know better than to run this script, root."  echo "Even root users get the blues... "  echofi  username=bozoNEWPASSWORD=security_violation# Check if bozo lives here.grep -q "$username" /etc/passwdif [ $? -ne $SUCCESS ]then  echo "User $username does not exist."  echo "No password changed."  exit $E_NOSUCHUSERfi  echo "$NEWPASSWORD" | passwd --stdin "$username"#  The '--stdin' option to 'passwd' permits#+ getting a new password from stdin (or a pipe).echo; echo "User $username's password changed!"# Using the 'passwd' command in a script is dangerous.exit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -