Tame Your Terminal Echo with `stty`
Quick Tip
Tame Your Terminal Echo with `stty`
Challenge: Sometimes when you’re typing commands, especially within scripts or interactive sessions, you might want to temporarily disable the echoing of characters to the terminal. This can be useful for security reasons (like masking password input, though `read -s` is preferred for that) or for creating custom interactive prompts where you control exactly what’s displayed.
The Solution: The `stty` command can be used to control terminal line settings, including echoing. To disable echo, you use `stty -echo`. To re-enable it, you use `stty echo`.
# Disable echoing stty -echo # Now type something, it won't appear on screen echo "You can't see what you're typing..." # Re-enable echoing stty echo
Why it works: `stty` modifies the terminal driver settings. The `-echo` flag tells the terminal not to send back (echo) the characters you type to the screen, effectively hiding them until you explicitly re-enable echoing with `stty echo`.
Pro-Tip: Combine `stty -echo` with `read` to create secure input prompts: `stty -echo; read -p “Enter secret: ” secret; stty echo; echo “Secret entered: $secret”`
Linux Tips & Tricks | © ngelinux.com | 6/25/2026
