Ubuntu default disable the root user and sudo runs the command needs super privilege.When you first run a sudo command,it asks for the login user password and it won’t ask again in 5 minutes,because the terminal remember the password for 5 minutes (the default timeout).This tutorial will show you how to change this default sudo command password timeout.

Edit sudoers.tmp using this command in Applications -> Accessories -> Terminal:

gksudo gedit /etc/sudoers

find the line says:

Defaults env_reset

change it into:

Defaults env_reset , timestamp_timeout=x

here change “x” to the minutes you want the terminal remember.

Note:You can set “x” to -1,so that the terminal will remember sudo password until you log-out or close this terminal window.To force terminal ask password again when running sudo command,use:

sudo -K