Tame Your Terminal with `stty` Echo Control
Quick Tip
Tame Your Terminal with `stty` Echo Control
Challenge: Sometimes you need to type sensitive information into a terminal, like passwords or API keys, and you want to prevent them from being displayed on the screen as you type (e.g., in a shared session or when using scripts). You might also want to temporarily disable echoing for other reasons, such as custom input handling in a script.
The Solution: The `stty` command can be used to control terminal settings, including echoing. To temporarily disable echoing, use:
stty -echo
To re-enable echoing, use:
stty echo
Why it works: `stty -echo` instructs the terminal driver to stop displaying characters as they are typed. This is a fundamental terminal control mechanism. `stty echo` reverts this setting.
Pro-Tip: You can combine `stty -echo` with `read -s` (silent read) in shell scripts to securely prompt for passwords without them appearing on the screen. For example: read -s "Enter password: " MY_PASSWORD; stty echo; echo "You entered: $MY_PASSWORD"
Linux Tips & Tricks | © ngelinux.com | 5/31/2026
