From man sudoers
:
timestamp_timeout
Number of minutes that can elapse before sudo will ask
for a passwd again. The timeout may include a frac‐
tional component if minute granularity is insufficient,
for example 2.5. The default is 15. Set this to 0 to
always prompt for a password. If set to a value less
than 0 the user's time stamp will never expire. This
can be used to allow users to create or delete their
own time stamps via “sudo -v” and “sudo -k” respec‐
tively.
As you can see, the default timeout of sudo
is 15 minutes. You can change this value in /etc/sudoers
.
You don't directly edit /etc/sudoers
, instead use visudo
to do it.
From man visudo
:
visudo edits the sudoers file in a safe fashion, analogous to vipw(8).
visudo locks the sudoers file against multiple simultaneous edits, pro‐
vides basic sanity checks, and checks for parse errors. If the sudoers
file is currently being edited you will receive a message to try again
later.
So, type sudo visudo
in a terminal, which will open the /etc/sudoers
file in nano
text-editor.
Look for this line:
Defaults env_reset
And add timestamp_timeout=X
where X is the time you want to set in minutes.
So as an example:
Defaults env_reset,timestamp_timeout=5
If you specify 0, you will always be asked the password. If you specify a negative value, the timeout will never expire.
Once done, save and exit.
See RootSudoTimeout
su
any more? Ever?sudo -i
and you have a root shell, ready for anyone to help shoothing themselves in the feet during as much time one like...su
needs root to have a password. By default, Ubuntu's root user doesn't have a password. Therefore, you can'tsu
to root.su
is working as intended here. Try with any user who has a password.sudo su
works just fine, though a bit repetitive.