By default, the timeout period of sudo is 15 minutes, that is to say, within 15 minutes after the last sudo command, you do not need to re-enter the password, and after 15 minutes, you need to re-enter the password.
Set sudo timeout
To set the sudo timeout, just specify timestamp_timeout=N
in the Defaults specification in /etc/sudoers
Here N is in minutes, for example, the following configuration sets the timeout to 10 minutes
Defaults timestamp_timeout=10
If N is set to 0, it means that you must enter the password every time you sudo
If N is set to less than 0, the sudo command will fail to execute