Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I had hibernated my laptop using

sudo pm-hibernate

and then woke it up some hours later to quickly check a document. I re-entered the above command and it worked without requiring a password. I assume this means that the sudo timeout is working from a relative time that is only ticking when the computer is awake, rather than an absolute system time.

I would prefer not to have sudo work without a password when I haven't entered it, in real terms, in the very recent future. Is there a way to enforce the timeout to not carry over like this while the system is in hibernation?

share|improve this question
add comment

1 Answer

Run the command using the -k option:

sudo -k pm-hibernate

Short version: -k means sudo will prompt for the password again next time.

From man sudo:

-k [command]

When used alone, the -k (kill) option to sudo invalidates the user's cached credentials. The next time sudo is run a password will be required. This option does not require a password and was added to allow a user to revoke sudo permissions from a .logout file. Not all security policies support credential caching.

When used in conjunction with a command or an option that may require a password, the -k option will cause sudo to ignore the user's cached credentials. As a result, sudo will prompt for a password (if one is required by the security policy) and will not update the user's cached credentials.
share|improve this answer
add comment

Your Answer

 
discard

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.