Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9

By default, sudo shows nothing while you type your password. You can make it show an asterisk for each character. This works on Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9.

  1. Open a new sudoers file safely with visudo -f /etc/sudoers.d/pwfeedback.
  2. Add the line Defaults pwfeedback and save.
  3. Open a new terminal and run sudo -k; sudo true to test.

To undo it, delete the file: rm /etc/sudoers.d/pwfeedback.

Note: Always edit sudoers files with visudo: it checks the syntax before saving, so a typo cannot lock you out of sudo. The asterisks also show how long your password is to anyone watching your screen.

Other useful sudo settings

Put each in its own file under /etc/sudoers.d/ with visudo -f:

  • Defaults timestamp_timeout=15: minutes before sudo asks for the password again (0 = every time).
  • Defaults passwd_tries=3: attempts before sudo gives up.
  • Defaults insults: a joke message after a wrong password (harmless, but not for production servers).

Check which rules apply to you with sudo -l.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)