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? – Mr Lister Sep 06 '15 at 21:26sudo -i
and you have a root shell, ready for anyone to help shoothing themselves in the feet during as much time one like... – Rmano Sep 06 '15 at 22:04sudo -i
orsudo bash
or similar. – reirab Sep 07 '15 at 05:44su
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. – muru Sep 07 '15 at 06:37sudo su
works just fine, though a bit repetitive. – coteyr Sep 07 '15 at 08:34sudo su
works becausesu
is executed as root, and the default Ubuntu configuration allows root tosu
without passwords. – muru Sep 07 '15 at 08:36su
to become root. It's a security measure to prevent the root-user from logging-in directly. Usingsudo
(andsu
) from a normal user-account, logs information about who became root. – Baard Kopperud Sep 07 '15 at 09:39su; apt-get install sudo
– DJMcMayhem Sep 07 '15 at 13:07