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 许可协议。转载请注明出处!
相关文章
Debian下SSH服务的安装与配置
https://cnzhx.net/blog/linux-server-ssh-key-auth-configuration/
2025-10-27 · 系统配置 · 约 1 分钟
在Nginx上配置https加密服务器
前言 最近开发微信小程序需要使用Https,于是折腾了一番。 超简单步骤 1. 申请SSL证书 一般云服务器提供商就会提供这种服务,我在腾讯云上申请了,十分钟就完成了。 2. 上传证书 上传到一个文件夹里面 3. 配置nginx 网络上的资料都是直接修改 /etc/nginx/nginx.conf 这个文件。 不过我的服务器上这个文件里头没有 server 这个节点可以配置。 因此需要修改 /et
2025-10-27 · 系统配置 · 约 1 分钟
Ubuntu-16-04-升级Python版本到3-6
前言 没办法,unity桌面实在是太好用了,Ubuntu18.04上安装了unity桌面毕竟不够完美,所以我昨天就降级到Ubuntu16.04,享受一波原生Unity桌面的快感。 一切都OK,不过Python版本有点低,所以要用万能PPA源升级一下。 操作 安装Python3.6 sudo add-apt-repository ppa:jonathonf/python-3.6 sudo apt-g
2025-10-27 · 系统配置 · 约 1 分钟
给你的Deepin系统换主题~
我现在的桌面: 因为美国封锁然后华为电脑用上Deepin系统的事情,Deepin系统最近名声大噪,其实Deepin本来的界面就很好看,号称打造最适合国人的系统不是盖的。 不过Deepin有一个坏处,就是默认主题的标题栏太大了…… 太占空间。所以我们要换主题折腾一下。 Deepin的桌面是Qt写的,所以首先要换KDE主题,然后再安排一下GTK3的主题,在Deepin系统设置里面换的主题就是GTK的,
2025-10-01 · 系统配置 · 约 1 分钟
讨论
共 0 条加载评论中…