返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
系统配置

Display asterisks when entering password in Linux terminal

Linux default password asterisks? That's actually a nice touch. One line of sudoers configuration does the trick, yet some people really do resort to scripts for this. Turning it off? That's just shooting yourself in the foot.

曦远 (DealiAxy)约 6 分钟
目录7 个章节

Preface

By default, the LinuxMint system displays asterisks during password input, which many users find to be a very good experience. While some people may consider this less secure, that's not a big deal—functionality is what really matters.

Configuration

This setting is located at /etc/sudoers.d/0pwfeedback.

This file contains a single line:

Defaults pwfeedback

If you don't want to display asterisks, just add an exclamation mark:

Defaults !pwfeedback

One-click Configuration Script

I also wrote a script that can enable or disable the asterisk display feature for sudo passwords with a single click.

# Enable Asterisk Display (开启星号显示)
```bash
curl -sSL https://gist.github.com/Deali-Axy/409d3d22099a6547f92f761a8cfeeab4/raw/e684032255024fe085663e29487ac0107abd06c6/pwfeedback.sh | sudo bash -s on

Disable Asterisk Display

curl -sSL https://gist.github.com/Deali-Axy/409d3d22099a6547f92f761a8cfeeab4/raw/e684032255024fe085663e29487ac0107abd06c6/pwfeedback.sh | sudo bash -s off


Below is the script source code.

Save as `pwfeedback.sh` and make it executable:

```bash
chmod +x pwfeedback.sh

The script content is as follows:

#!/bin/bash

Toggle Asterisk Display for sudo Password Input

Usage: ./pwfeedback.sh on|off

set -e

CONFIG_FILE="/etc/sudoers.d/0pwfeedback"

if [ "$EUID" -ne 0 ]; then echo "Please run this script as root or with sudo" exit 1 fi

case "$1" in on) echo "Defaults pwfeedback" > "$CONFIG_FILE" echo "Enabled: sudo will display asterisks (*) when entering the password" ;; off) echo "Defaults !pwfeedback" > "$CONFIG_FILE" echo "Disabled: sudo will not display asterisks when entering the password" ;; *) echo "Usage: $0 {on|off}" exit 1 ;; esac


You can use the following command to toggle it:

```bash
# Enable Asterisk Display
sudo ./pwfeedback.sh on
# Disable asterisk display
sudo ./pwfeedback.sh off

References

_EOF_

Display asterisks when entering password in Linux terminal

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

Nginx配置http跳转https-强制https访问

前言 最近上线了好几个项目,同时也申请了相应的SSL证书,不过发现了一个问题,用户在浏览器直接输入域名的时候,浏览器默认访问的是http站点,然而我们的网站只支持https访问,所以就访问不了咯。 其实可以在nginx全局配置里面把所有访问重定向到https,不过服务器有些站点是提供http服务的,所以只能每个站点分别配置。 根据搜索引擎找到的资料,本文总结了三种配置方法,有需要的朋友可以选择中意

2025-10-27 · 系统配置 · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…