1

Within a single bash session I am repeatedly re-running a command prefixed by sudo. Typically the password should be requested once and then cached. However, the present behavior is that the password is requested each time.

I opened another bash window and the same behavior is observed.

What may be causing that behavior?

2 Answers 2

1

User Shawn J Goff answered this particular quirk in another question that was the reverse of this one. The answer is here, and as follows:

From man sudoers:

timestamp_timeout

Number of minutes that can elapse before sudo will ask for a passwd again. The timeout may include a fractional component if minute granularity is insufficient, for example 2.5. The default is 5. Set this to 0 to always prompt for a password. If set to a value less than 0 the user's timestamp will never expire. This can be used to allow users to create or delete their own timestamps via sudo -v and sudo -k respectively.

2
  • 1
    Why would the behavior spontaneously change? I had not touched sudoers. Commented May 27, 2015 at 18:48
  • That, I don't know that I can answer. Of course, any person or process executing with su or root privilege would be able to modify sudoers, including a process invoked during install, but I honestly can't think of an application that would make a change to force you to enter your password every single time, other than a potential keylogger? Commented May 27, 2015 at 18:56
0

I use the following command at the beginning of a session in bash on a Macintosh. It's great if I plan to use multiple commands that need sudoer access. All commands typed after this process will be executed as root.

sudo -s

Example:
Last login: Tue Jun 2 13:38:19 on ttys000
HostName:~ UserName$ sudo -s
Password:
bash-3.2# whoami
root
bash-3.2#

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.