Tame Your Terminal with `stty` Echo Control
Quick Tip
Tame Your Terminal with `stty` Echo Control
Challenge: Sometimes you need to run commands that echo sensitive information to your terminal (like passwords during an interactive prompt), or you want to prevent accidental display of input characters.
The Solution: The `stty` command can control terminal line settings, including echoing. You can temporarily disable it and re-enable it.
# Disable echoing stty -echo # Run your sensitive command (e.g., read -s -p "Enter password: ") # Re-enable echoing stty echo
Why it works: `stty -echo` instructs the terminal driver to stop displaying characters as they are typed, and `stty echo` restores this behavior. This is particularly useful when scripting interactive prompts where you don’t want passwords or other sensitive data to be visible.
Pro-Tip: For a more robust solution in scripts, consider using `read -s` which is specifically designed for silent input without needing to manually manage `stty`.
Linux Tips & Tricks | © ngelinux.com | 5/30/2026
