Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Bash builtin read command doesn't seem to support it, now I need to let user input a password while no echo should be displayed, what tool can I use?

share|improve this question
help read|grep echo: "-s do not echo input coming from a terminal" – donothingsuccessfully Nov 16 '12 at 7:25
@donothingsuccessfully This -s extension of read is not standard. You may not be able to use it on any Unix/Linux. – Totor Apr 22 '13 at 21:26
up vote 23 down vote accepted
stty -echo
IFS= read -p 'Enter password: ' -r password
stty echo
printf '\nPassword entered: %s\n' "$password"
  • stty -echo turns off the terminal echo, which is the display you're talking about;
  • IFS= is necessary to preserve whitespace in the password;
  • read -r turns off backslash interpretation.

In bash you can also use read -s, but this feature isn't standard across shells.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.