Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to read passwords in bash scripts in a way like tools which are not showing it on terminal ?

(Changing font to black on black might be tricky by easy to copy&paste - so it's not solution)

share|improve this question
For anyone reading this: do NOT read in passwords with echo on and black-on-black. The password is still transmitted, and if the terminal doesn't know the terminal directives you've used, characters will echo visibly. Turn echo off. Use termios, stty, read -s, anything that does it. –  Alexios Mar 26 '12 at 22:14
That's why I've wrote, that it is not a solution ;). –  Grzegorz Wierzowiecki Mar 26 '12 at 22:18
Indeed! Sometimes people skim questions and come to misguided conclusions. :) –  Alexios Mar 26 '12 at 22:25

2 Answers 2

up vote 14 down vote accepted

From help read:

-s        do not echo input coming from a terminal
share|improve this answer
Great. It's not written in my man read, I haven't check in help read. Good to know. –  Grzegorz Wierzowiecki Mar 26 '12 at 21:19
@GrzegorzWierzowiecki: You are viewing the wrong manual. you have to read the manual of bash i.e man bash and there you can find -s option Silent mode. If input is coming from a terminal, characters are not echoed. –  pradeepchhetri Mar 27 '12 at 6:34

Your question reads kind of different "in a way like tools???" so I don't exactly know if this will work for you:

system1 $ passwd=abc123
system1 $ printf "%s\n" "${passwd//?/*}"
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.