One of my friends recently switched over from Windows to Ubuntu Linux. After spending a week or so with the new operating system, he came up with a question: “How do you get the system to display asterisks while typing a sudo password?”
He explained that he types very fast, often without looking at the keyboard. While this does result in some typos here and there, typing the correct
sudo password in one go has proved to be very challenging primarily because nothing shows up when you type the password.
I have to admit that I don’t even come close to the speed at which he types, so that’s probably the reason I never faced such a problem. Anyway, if you are having the same problem, here is a neat little solution to the problem.
Steps to enable password feedback in sudo
For starters, the
sudo command in Ubuntu lets you temporarily acquire superuser privileges for work that requires you to act as a root user. To make any changes to the way the
sudo command behaves, you have to tweak the “/etc/sudoers.tmp” file.
In order to make changes in “/etc/sudoers.tmp,” use the following command. (Keep in mind that this is the recommended way to edit this file.)
The above command will open the file in your terminal.
Notice that the first line of the file also stresses what I just said: “This file MUST be edited with the ‘visudo’ command as root.”
Moving on, what you need to do here is to replace the line
Unlike the vi or vim editors, all you have to do here is bring your cursor to the end of the line and start making the change. Once you’re done with the change, press “Ctrl + X” which will result in the editor asking you to confirm that you want to keep the changes. Press “Y” to confirm, and then hit the Enter key to exit.
Now whenever you run a command with
sudo, you’ll see that the password you type becomes visible in the form of asterisks.
Needless to say, to undo the behavior, you just have to undo the changes you made to the “/etc/sudoers.tmp” file – just bring your cursor to the end of the line and remove
,pwfeedback by pressing the backspace key on your keyboard.
Agreed, it’s a niche requirement – I have not seen many people asking how to do this – but the solution surely adds to your knowledge about the sudo command and Ubuntu in general. Go ahead and give this solution a try. Who knows, you might end up liking the new