|To set the sudo password timeout value, use the passwd_timeout parameter. First open the /etc/sudoers file with super user privileges using sudo and visudo commands like so:
$ sudo visudo
Then add the following defaults entry, it implies that the sudo password prompt will time out after 20 minutes once sudo is invoked by a user.
Note: You can set whatever time you want in minutes and make sure to wait before it times out. You can also set time to 0 if you want a password prompt for every sudo command you execute, or disable password prompt forever by setting the value -1.
The screen shot below show the defaults parameters I have set in my /ec/sudoers file.
Change sudo Password Timeout
Save the file by pressing [Ctrl + O] and exit using [Ctrl + X]. Afterwards test if the setting is working by running a command with sudo and wait for 2 minutes to see if the password prompt will time out.