Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

sudo asks for the user's password every so often when using bash. The answers to this explains how to change that time out.

I was wondering, however, whether it would be possible to sync this. I have a rather strong password, and when I come back to my locked system, I have to enter the password first into the ubuntu screensaver, and then every single shell I am working with... so often 4-5 times in a row... Is there a way all of those entries can be combined? e.g. when the screen saver just unlocked or another terminal used sudo, sudo won't ask again?

share|improve this question
up vote 2 down vote accepted

Is there a way all of those entries can be combined?

What I believe you are looking for is a result of the tty_tickets tickets setting. With recent version of sudo this defaults on, though this wasn't true in the past.

man sudoers.

tty_tickets If set, users must authenticate on a per-tty basis. With this flag enabled, sudo will use a file named for the tty the user is logged in on in the user's time stamp directory. If disabled, the time stamp of the directory is used instead. This flag is on by default.

share|improve this answer
Thanks, that brings it down to two – Cookie Feb 23 '12 at 12:22

I don't think this is possible by configuration alone.

The thing is, when you unlock your screensaver, you're not elevating privileges. You're not even invoking sudo to unlock it. sudo and you screensaver just validate the input password against the same database. So it seems like you're doing the same thing twice, but you aren't.

Your screensaver could pass on your input directly to sudo to automatically elevate when you unlock it, but that would be horrible.

So this leaves the annoyance that you have to re-elevate in every single terminal window after unlock. I'm afraid this is by design as well. Sharing (or manipulating) the elevated privileges state between processes does not sound like something I would want.

I'm very sure you could write some sort of script that enumerates all open terminal windows and inserts a sudo and directly inputs your password. Then you could try to invoke that script automatically when your screensaver is unlocked.
But you don't want your root password somewhere in some script that inserts it automatically into a bunch of windows. You dont.

tl;dr Don't automate sudo.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.