How to display Asterisks(*) when you type Password in Linux Terminal

As we all know terminal is a crucial tool for Linux admin, which allow them to perform any kind of task in a secured manner.

When you type password in any of the GUI portal that will be masked with asterisks like  “*******”.It’s a built-in security mechanism that prevent others to view your password when you are typing.

But, in Linux terminal it doesn’t show anything when you enter the password. It’s common in Linux terminal and most of us adapted this feature.

There are chances that you may type your password wrongly multiple times, which will really irritate you.To avoid this situation, you need to get an Asterisks output when you type password.It shows you, how many characters that you have entered. It helps you to re-check that you have missed any characters or typed any extra characters in password.

In this article, we will tell you how you can enable this feature in Linux Operating System.

I have tested this on Ubuntu 18.04, CentOS 6/7 and Manjaro and it’s working fine. I hope, it will work on these clone as well without any issues.

By default you will be getting the below output when you entering the password.

$ sudo apt update
[sudo] password for daygeek: 

How to display Asterisks when you type password in Linux terminal?

To do so, you need to append the pwfeedback word in /etc/sudoers file.

Note : It’s a best practices to backup a files before making any changes in Linux. So, backup the sudoers file before appending anything on it.

This will help you to restore it to previous state without any damage, if something goes wrong.

$ sudo /etc/sudoers /etc/sudoers.bk

Once you done the backup, you are ready to go.

It can be done in two ways. Either append the following word pwfeedback in the file as shown below or append Defaults pwfeedback as a new line at end of the file.

# visudo

Defaults        env_reset,pwfeedback


# visudo

Defaults        pwfeedback

Once you done the changes, just save and exit the file.

We can test this out by calling any commands with sudo as shown below.

$ sudo pacman -Syu
[sudo] password for daygeek: *********

We are preparing all the articles in-depth to understand by all level of Linux administrators. If you feel this article is useful , Please spend less than a minute to share your valuable comments in our commenting section or spread this on Social media.

Please stay tune with us…Good Luck.

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

One Comment on “How to display Asterisks(*) when you type Password in Linux Terminal”

  1. Hello, I’ve tried to do it on CentOS 7 with no luck so far. tried both approaches(appending the new line at the end of the file and adding the pwfeedback to env_reset line
    Any ideas on how to change it?

Leave a Reply

Your email address will not be published. Required fields are marked *