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系统的鼠标滚轮的速度
Linux默认的鼠标滚轮实在太慢了,总是让我有一种Linux很卡的错觉,而且还不像Windows那样可以直接修改所有程序中的鼠标滚轮速度,不过没事,可以用imwheel这个工具来修改~ 安装 Debian系: sudo apt install imwheel Arch: sudo pacman -S imwheel 配置 创建~/.imwheelrc文件 nano ~/.imwheelrc 编辑内
2025-10-27 · 系统配置 · 约 1 分钟
Nginx配置http跳转https-强制https访问
前言 最近上线了好几个项目,同时也申请了相应的SSL证书,不过发现了一个问题,用户在浏览器直接输入域名的时候,浏览器默认访问的是http站点,然而我们的网站只支持https访问,所以就访问不了咯。 其实可以在nginx全局配置里面把所有访问重定向到https,不过服务器有些站点是提供http服务的,所以只能每个站点分别配置。 根据搜索引擎找到的资料,本文总结了三种配置方法,有需要的朋友可以选择中意
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 分钟
别再手动复制SSH公钥了,Linux服务器一键从GitHub快速导入公钥
输入GitHub用户名就自动导入SSH公钥?Ubuntu这懒人功能挺省事。原理不就是爬取`https://github.com/用户名.keys`吗?手动用`curl`也能实现,装`ssh-import-id`更高效,但谁稀罕这些花里胡哨的。
2026-03-11 · 系统配置 · 约 1 分钟
讨论
共 0 条加载评论中…