How do I make sudo remember my password for longer?

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.

Asked By: Dr Manhattan


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.

Answered By: Jakuje

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

Example: to get password remembered for 5 hours

Defaults        timestamp_timeout=300
Answered By: JJoao

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

Answered By: Eric Korolev
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.