25

How do I make sudo remember my password for longer so that I don't have to keep typing it? I do not want to sudo su and execute commands as root all the time.

I am on Arch Linux and have tried to google this but I get examples to change my password, which is not what I'm after.

1
  • 7
    Point of order, sudo does not "remember your password" so much as it remembers your session -- pam_sudo remembers that you authenticated correctly in that particular console session and retains that flag for passwd_timeout seconds.
    – Shadur
    Jul 18, 2015 at 9:13

3 Answers 3

29

There is timestamp_timeout option in your /etc/sudoers. You can set up this option to number of minutes. After that time it will ask for password again. More info in man sudoers.

And make sure you edit your sudoers file using visudo, which checks your syntax and which will not leave you with wrong configuration and inaccessible sudo.

1
  • 2
    If you rely rely hate passwords, then you can configure sudoers so that you do not need one. You can also do this for just some individual commands / users. Jul 18, 2015 at 10:09
27

There is a timestamp_timeout option in your /etc/sudoers...

Example: to get password remembered for 5 hours

Defaults        timestamp_timeout=300
2
  • I think this is actually what i was after, the passwd_timeout is only how long it takes for the password prompt to stay up with no input Jul 18, 2015 at 11:40
  • if that's true can you please accept this one instead? the current situation is misleading in that case Jul 18, 2015 at 14:04
1

open /etc/sudoers for editing in vi editor

sudo visudo

enter your password

in vi editor to go to the end of the line and go into edit mode type A and ENTER

add this line where 300 is the new timeout in minutes.

Defaults        timestamp_timeout=300

to exit vi edit mode type ESC button

to save file type :w and ENTER

to exit type :q and ENTER

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .