Change the sudo Password Timeout in Ubuntu

Spread the love

In Ubuntu (and any other Ubuntu-based distro), when you use a “sudo” command, the system will prompt you for your password. After the first “sudo” command, the system will remember your password for the next 15 minutes so you don’t have to enter any more password for subsequent “sudo” command. If, however, you feel that the 15 minutes is a bit too long/short, here is how you can change it.

1. Open a terminal and type:

sudo visudo

2. In the file that open, scroll down till you see the line:

Defaults        env_reset

Change it to

Defaults        env_reset, timestamp_timeout=X

where X is the time (in minutes) that the sudo password will timeout. You can set X to the value you want.

Note:

  • If you set X to “-1”, it will revoke the password prompt, which is not advisable.
  • If you set X to “0”, the system will prompt you for password everytime you use the “sudo” command

3. Press “Ctrl + x” to exit. Don’t forget to press “y” to save the changes.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Damien Oh

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Comments (1)