Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How I can make sudo Ubuntu 10.04 session an hour and not few minutes?

Now I have to write my password for sudo commands every few minutes.

share|improve this question
5  
"Now i have to write my password for sudo commands every few minutes" Right. That's the point. :-) –  T.J. Crowder Jun 7 '10 at 10:22

4 Answers 4

up vote 9 down vote accepted

Instead of making the sudo session longer, you could actually log in as root.

sudo su

Anything you do afterwards is done as root. You don't even have to enter sudo anymore.

You can log out any time you want.

exit
share|improve this answer
2  
AFAIK, this is only working for the shell prompt window you currently use, not all applications on the X session you currently run. And this has an advantage. You can have your regular applications, shells and others, while keeping one shell (sudo su) with root privileges. –  jfmessier Jun 7 '10 at 12:29
    
Thank you very much –  Yosef Jun 7 '10 at 13:02
    
Much less safe than typing sudo before the few commands you want to run as root, with the convenience of not having to retype the password. See Bobby's much better answer below. –  AlcubierreDrive Aug 2 '12 at 2:52
1  
This doesn't answer the question, and is more dangerous. It short-circuits sudo's behavior of logging commands entered, and it completely removes the timeout (which is good security practice, the OP was just asking how to change the tradeoff). –  Andrew Ferrier May 2 '13 at 18:03

Disclaimer: This is not recommended for security reasons! One of the reasons why Linux is so safe are the user privileges.

You can edit the sudo settings file with the following command:

  sudo visudo

And then change the line

  Defaults      env_reset

to

  Defaults      env_reset,timestamp_timeout=x

x is in minutes by the way. A negative value for x such as -1 will cause sudo to ask for user password only once per session.

  Defaults:user      timestamp_timeout=x

will apply the setting only to the named user.

One word of warning: Do not edit this file with another editor/command! If you lock yourself out of your system, reboot into single-user/recovery mode and run visudo there.

share|improve this answer
    
Thank you very much Bobby! –  Yosef Jun 7 '10 at 13:01

I prefer "sudo -i" after logging in as user.

The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of the target user as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed. sudo attempts to change to that user's home directory before running the shell. It also initializes the environment, leaving DISPLAY and TERM unchanged, setting HOME, SHELL, USER, LOGNAME, and PATH, as well as the contents of /etc/environment on Linux and AIX systems. All other environment variables are removed.

share|improve this answer

You can use pamusb.

"pam_usb provides hardware authentication for Linux using ordinary USB Flash Drives "

share|improve this answer
    
Not what he asked for, but maybe a could solution which isn't such a worst-case security scenario. –  Bobby Jun 7 '10 at 10:45
    
Thank you very much –  Yosef Jun 7 '10 at 13:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.