password feedback in terminal

Post your tutorials and howtos here.
User avatar
Posts: 297
Joined: 07 Nov 2013 08:06
Location: Rovaniemi, Finland

password feedback in terminal

Postby just » 10 Oct 2014 08:30

have you ever asked yourself: "why there's no any feedback in terminal while i'm typing in my password for a command prefixed by sudo?"

when i hit Alt+F2 to enter some command with kdesu in kde, those bullets in Password: field are extremely handy. at least, i can see how much chars i've already typed in, or how much of them i've cancelled with backspace, if i'm editing the password.

in terminal, by default, there's no such type of feedback. is it possible to have it? yes:

just@alexsol ~ $ sudo apt-get purge $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)
[sudo] password for just:

my password is 9 chars long, so there're 9 asterisks. they are displayed only until the password is being typed in/edited, and disappear immediately after we hit Enter:

just@alexsol ~ $ sudo apt-get purge $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)
[sudo] password for just:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-headers-3.14-1-amd64* linux-headers-3.14-1-common*
linux-headers-3.14-2-amd64* linux-headers-3.14-2-common* linux-headers-amd64*
linux-image-3.14-1-amd64* linux-image-amd64*
0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
After this operation, 199 MB disk space will be freed.
Do you want to continue? [Y/n]

how to get password feedback in terminal? all we need to do is to edit /etc/sudoers file:

Code: Select all

sudo visudo
the file will be opened in the default text editor for our current de (vi, vim. nano, other).

look for any line that begins with Defaults. there could be only one such line, or no one at all. in the default SolydK-2014.07-64bit installation there are three such lines.

add (insert) a new line to the file, rigorously following the format of already existing Defaults lines. the line to insert is:

Code: Select all

Defaults	pwfeedback
in SolydK-2014.07 the format of existing lines is:
  • text starts in the first column
  • Defaults starts with the capital D
  • all others are lower case letters
  • pwfeedback is separated from Defaults by one, and only one TAB character, not by N spaces
the new line may be inserted at any point of the file:
  • before already existing group of Defaults lines
  • after it
  • at the end of the file, as the last one
if Defaults line doesn't exist at all, simply add it at the end of the file. use one TAB or one SPACE to separate pwfeedback from Defaults.

exit from editor, saving the file:
  • vi, vim: Esc :wq Enter
  • nano: Ctrl-X y Enter
close the terminal.


from now on, every time you open the terminal to enter a command with sudo, the password will be echoed with asterisks as you type it in or edit it.

User avatar
Posts: 1244
Joined: 25 Aug 2013 20:01
Location: Spain

Re: password feedback in terminal

Postby Snap » 10 Oct 2014 09:26

Cool tip. Thank you.
This likely means that your installation is broken. -Mr Pixbuf.


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests