The `stty` Trick for Taming Terminal Echo
Quick Tip
The `stty` Trick for Taming Terminal Echo
Challenge: Sometimes, when working with sensitive information in the terminal, like passwords or API keys, you might want to prevent them from being displayed on the screen as you type. This is especially useful in scripts or interactive prompts.
The Solution: The `stty` command can be used to temporarily disable terminal echoing.
stty -echo
Why it works: The `stty` command configures the current terminal’s line discipline. The `-echo` option tells the terminal not to display characters as they are typed, effectively making them invisible to the user but still processed by the shell.
Pro-Tip: To re-enable echoing, you can use stty echo. You can also combine this with `read -s` in scripts for securely reading passwords without echoing.
Linux Tips & Tricks | © ngelinux.com | 6/13/2026
