Disable Per Session
This command below will prompt you for your sudo password once and never again until you log out and in again.
sudo -i
Extend Inactivity Timeout
The default inactivity timeout is usually 5 minutes before Linux will prompt for your sudo password again. You can extend this timeout by editing the sudoers file. The visudo
command opens an editor and points it to the sudoers file (Ubuntu defaults to nano, other systems use Vi)
sudo visudo
Look for the line Defaults env_reset
Add to the end of it ,timestamp_timeout=60
(where 60 is the amount of minutes).
Defaults env_reset,timestamp_timeout=60
Save changes and close (In nano, press CTRL
+ X
and then press y
and ENTER
)
Disable Permanently
You can disable this sudo password prompt permanently using the sudoers file. However, it is not recommended that you do this for security reasons. Unauthorised commands could be run by someone or a malicious script in your absence. If you understand the implications, run visudo
to open the sudoers file (Ubuntu defaults to nano, other systems use Vi)
sudo visudo
At the bottom of the file, paste in the following, replacing username
with your own.
username ALL=(ALL) NOPASSWD:ALL
Save changes and close (In nano, press CTRL
+ X
and then press y
and ENTER
)
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.
That 5-minute timeout is way too short!
Thanks so much for the “sudo -i”
Simply perfect. Thank you!?