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.
目录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 许可协议。转载请注明出处!
相关文章
在Linux系统上一键配置DoH,解决DNS解析被污染
DNS解析被污染?换DoH不就得了。云flare那破工具简单得可笑,国内DNS上游直接用就行。一行配置搞定,谁还不会啊?
2025-10-02 · 系统配置 · 约 1 分钟
Linux设置系统邮件转发到指定邮箱
前言 在Linux的操作中,有的时候每敲一下回车,就出来You have new mail in /var/spool/mail/root的提示,究竟是为什么呢? Linux 系统经常会自动发出一些邮件来提醒用户系统中出了哪些问题(收件箱位置:/var/mail/)。可是这些邮件都是发送给 root 用户的。出于系统安全考虑,通常不建议大家直接使用 root 帐户进行日常操作。所以要想点办法来让系
2025-10-27 · 系统配置 · 约 1 分钟
服务器时间漂移,如何开启Linux NTP自动同步
本文记录了作者在服务器运维中发现时间漂移问题,并通过启用NTP同步、使用Chrony等工具进行排查与解决的全过程。文章强调了NTP同步的重要性,介绍了排查思路和高效工具的使用,以及如何同步硬件时钟(RTC),为服务器时间精准同步提供了解决方案。
2025-10-27 · 系统配置 · 约 1 分钟
配置MariaDB数据库服务端远程访问
操作步骤 开启远程访问权限 连接MariaDB数据库,执行以下命令开启远程访问。 grant all privileges on *.* to 'root'@'192.168.248.248' identified by 'password'; flush privileges; 如果需要任意IP地址访问,就把IP地址换成%。 修改配置文件 在网络上能搜索到的资料都只说了第一点,然而亲测之后并没有
2025-10-27 · 系统配置 · 约 1 分钟
讨论
共 0 条加载评论中…