Created
October 1, 2025 14:30
-
-
Save Deali-Axy/409d3d22099a6547f92f761a8cfeeab4 to your computer and use it in GitHub Desktop.
一键开启或关闭 sudo 输入密码时的星号显示功能
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 一键配置 sudo 密码输入是否显示星号 | |
| # 用法: ./pwfeedback.sh on|off | |
| set -e | |
| CONFIG_FILE="/etc/sudoers.d/0pwfeedback" | |
| if [ "$EUID" -ne 0 ]; then | |
| echo "请使用 root 或 sudo 运行该脚本" | |
| exit 1 | |
| fi | |
| case "$1" in | |
| on) | |
| echo "Defaults pwfeedback" > "$CONFIG_FILE" | |
| echo "已开启:sudo 输入密码时会显示星号 (*)" | |
| ;; | |
| off) | |
| echo "Defaults !pwfeedback" > "$CONFIG_FILE" | |
| echo "已关闭:sudo 输入密码时不显示星号" | |
| ;; | |
| *) | |
| echo "用法: $0 {on|off}" | |
| exit 1 | |
| ;; | |
| esac |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
开启星号显示
curl -sSL https://gist.github.com/Deali-Axy/409d3d22099a6547f92f761a8cfeeab4/raw/e684032255024fe085663e29487ac0107abd06c6/pwfeedback.sh | sudo bash -s on关闭星号显示
curl -sSL https://gist.github.com/Deali-Axy/409d3d22099a6547f92f761a8cfeeab4/raw/e684032255024fe085663e29487ac0107abd06c6/pwfeedback.sh | sudo bash -s off