Any easy way to reduce/remove sudo rights elevation messages in a terminal?

Hey everyone!

We have to approve sudo rights elevation many times a day, and these attempts require password entry or a fingerprint, and generate several lines of noise in the terminal output (especially if first attempt is unsuccessful).

These lines of information are useless after the fact, and just clutter the copied output or screenshots.

Is there an easy way to make them disappear after successful rights elevation? Or at least shrink to a single line.

Probably not with sudo as the text at that point has been sent to the terminal already. And I guess the text is not generated by sudo but by PAM, so I don’t think sudo would even know what text has been printed so it could remove it with some control codes.

But since you are using Konsole (and KDE?), you could look into using pkexec. It uses Polkit and opens a separate window for your fingerprint/password, which keeps the terminal window clean. You can even configure a desktop effect to subtlely darken the desktop while it’s waiting for your credentials.

sudo tee /etc/sudoers.d/99-local << "EOF" > /dev/null
%wheel ALL=(root) NOPASSWD: /usr/local/bin/fupd
EOF
sudo tee /usr/local/bin/fupd << "EOF" > /dev/null
#!/usr/bin/bash
if [ "${EUID}" -ne "0" ]; then exec sudo "${0}" "${@}"; fi
dnf upgrade "${@}"
EOF
sudo chmod +x /usr/local/bin/fupd

This is solving the issue with the authentication text in the terminal by getting rid of the authentication altogether (for a single command, granted).

Every other sudo invocation will still have the authentication output. And a general NOPASSWD for all commands would feel to me a bit like throwing the baby out with the bathwater.

Or go with run0, which also prompts for credentials in a GUI window.