How to change the number of minutes that the sudo password is cached

mikhomikho AdministratorHosting ProviderOG

Written by @mikho, 4 May 2021
Article was migrated from WordPress to Vanilla in March 2022

image

This is a really QUICK TIP!

When you run any command as root, using sudo, the password is remembered for 15 minutes by default.
If you want to change the time that the password is cached, open the terminal (as root) and run:

editor /etc/sudoers 

Find this line in the file:

defaults env_reset

And change it into:

defaults env_reset , timestamp_timeout=x

where “x” is the time in minutes that the password will be cached.

Save and exit and work is done!

Comments

  • If you want to change the time that the password is cached, open the terminal (as root) and run:
    editor /etc/sudoers

    Isn't it generally recommended to use visudo to edit the sudoers file?

    Website: thomassen.sh

    Discord: Decicus#0001

  • MasonMason AdministratorOG

    @Decicus said:

    If you want to change the time that the password is cached, open the terminal (as root) and run:
    editor /etc/sudoers

    Isn't it generally recommended to use visudo to edit the sudoers file?

    Probably not a bad idea for newish Linux users as it checks for syntax issues before making the change.

    @mikho - possible amendment to the blog post to make it noob-friendly, if you agree with the above.

    Head Janitor @ LES • AboutRulesSupportDonate

  • mikhomikho AdministratorHosting ProviderOG

    There is a visudo post coming up shortly.
    Which shows the recommended way to edit the sudoers file.

    I will add the link to the new post and more text to explain that it IS possible to do it this way, but there are also other ways.

    Thanked by (1)Decicus
Sign In or Register to comment.