Home Linux Tips & Tricks How To Display Asterisks When You Type Password In Terminal

How To Display Asterisks When You Type Password In Terminal

By sk
Published: Last Updated on 3.7K views

When you type passwords in a web browser login or any GUI login, the passwords will be masked as asterisks like ******** or bullets like •••••••••••••. This is the built-in security mechanism to prevent the users near you to view your password. But when you type the password in Terminal to perform any administrative task with sudo or su, you won't even the see the asterisks or bullets as you type the password. There won't be any visual indication of entering passwords, there won't be any cursor movement, nothing at all. You will not know whether you entered all characters or not. All you will see just a blank screen!

Look at the following screenshot.

Sudo password prompt

Sudo password prompt

As you see in the above image, I've already entered the password, but there was no indication (either asterisks or bullets). Now, I am not sure whether I entered all characters in my password or not. This security mechanism also prevents the person near you to guess the password length. Of course, this behavior can be changed. This is what this guide all about. It is not that difficult. Read on!

Display Asterisks When You Type Password In terminal

To display asterisks as you type password in Terminal, we need to make a small modification in /etc/sudoers file. Before making any changes, it is better to backup this file. To do so, just run:

$ sudo cp /etc/sudoers{,.bak}

The above command will backup /etc/sudoers file to a new file named /etc/sudoers.bak. You can restore it, just in case something went wrong after editing the file.

Next, edit /etc/sudoers file using command:

$ sudo visudo

Find the following line:

Defaults env_reset

Add an extra word ,pwfeedback to the end of that line as shown below.

Defaults env_reset,pwfeedback

Then, press "CTRL+X" and "Y" to save and close the file. Restart your Terminal to take effect the changes.

Now, you will see asterisks when you enter password in Terminal.

Display Asterisks When You Type Password In terminal In Linux

Display Asterisks When You Type Password In terminal In Linux

If you don't like to see a blank screen when you type passwords in Terminal, the small tweak will help. Please be aware that the other users can guess the password length by looking at the asterisks when you type it. If you don't mind it, go ahead make the changes as described above to make your password visible (masked as asterisks, of course!).

You May Also Like

1 comment

Rick Stanley January 8, 2018 - 2:24 am

This, of course ass/u/me’s that sudo is used. Sudo is not setup by default on Debian systems (And possibly other Distros as well.) when a password has been set for root.

On any system I own or am the Sysadmin, sudo has been removed completely, therefor there is no ‘/etc/sudoers’ file! On my systems ‘su’ is used exclusively! I too would not recommend showing asterisks for the passwords. I can see no practical reason to use this tweek on any system, either a personal or business Linux system.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More