Change sudo time and show asterisks when typing
Not enough time!
When you use sudo in Linux, a session that lasts 15 minutes by default, is created. This may be not enough time for a user to complete a task as root, in my case, everytime QownNotes package is updated (usually every day!) it last more than this time to finish it compilation process, so I need to reenter my password, but when this terminal window is in the background the time for asking the password also expires and I need to restart the update process.
How to make sudo sessions last longer
This is a really easy, you just need to use visudo tool
sudo visudo
and change the line:
Defaults env_reset
to:
Defaults env_reset,timestamp_timeout=30
Where, of course, timeout=30
refers to the number of minutes you want the session to be available. You can also change this value to 0
if you want to ask for the password every time sudo is used, or use -1
in case you don’t want to ask for the password at all.
Aster*sks
If you don’t like to be blind when typing your passwords in the terminal, you can also add a little ‘hack’ when editing /etc/sudoers to make the shell show you asterisks instead of a desert of emptiness 🙁
sudo visudo
adding:
Defaults env_reset,pwfeedback
All in one
Finally, you maybe would like to include all this in a script so here it is:
echo 'Defaults env_reset,pwfeedback,timestamp_timeout=30' | sudo EDITOR='tee -a' visudo