3

When typing my password in a console I sometimes notice I did not write it properly. In these cases, I normally use Ctrl + u to reset and start from scratch.

However, there are cases in which I know I typed everything fine but the first letter. Is there a way to go to the beginning of the word and replace it?

The underlying problem is that I don't know which editor is being run when you type a password. I don't know if I can use vim expressions and/or the buttons Home in my keyboard.

I do see that Backspace does work, but Home does not, neither the arrows . Using Ctrl-a as indicated in Shell: how to go to the beginning of line when you are inside a screen? does not work either.

I am on GNU bash, version 4.3.11.

fedorqui
  • 7,861
  • 7
  • 36
  • 74
  • @maulinglawns when I am in the normal command line, it works also to me. However, when typing a password it does not: I start typing, I press Ctrl+A, then Supr and finally the correct character. If I then press Enter, the password is not accepted. It is bad there is no way to see the password while you are typing it, it would help to understand what is happening, because it can well be an issue with Supr. – fedorqui Oct 19 '16 at 10:03

1 Answers1

3

Control-a is readline keybinding that bash uses by default. Other programs such as sudo or su apparently don't use it (might look into the their source code to learn how they handle input). But you can always simulate readline with a program called rlwrap. For example:

$ rlwrap  sudo echo hi
Password: ********

Now * are shown so you know where the pointer is and you can press Control-a to go to the beginning of the line.

  • This works! Even pressing did go to the beginning of the line, so I could Supr and type the correct character. – fedorqui Oct 19 '16 at 10:28