Skip to content

Did you know?

sudo remembers your password for 15 minutes; sudo -k makes it forget right away.

Run it before you step away from an open terminal.

Explained

After you enter your password, sudo doesn’t ask again for a while: 15 minutes by default, in that terminal. Anyone who sits down at your unlocked terminal in that time can run commands as root without knowing the password.

Clear the cached credentials immediately:

sudo -k

The next sudo command asks for the password again. sudo -K (capital K) removes your cached credentials for all terminals.

To change the timeout for everyone, edit the sudoers file with visudo (never directly) and add a line such as:

Defaults timestamp_timeout=5

The value is in minutes; 0 asks for the password every time. Of course, locking your screen is still the better habit. On Linux desktops that is usually Super+L.

Learn more

← All tech tips · Suggest a fix

Back to top