Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just set-up ubuntu 9.10 on my computer, and I'm trying to figure out how to avoid typing a password on every action that requires sudo privileges. I just want to type a password once on login and have all rights throughout my session. Also, I'd rather not login as root, but using my own username and settings. Thanks.

share|improve this question
1  
This is pretty dangerous and is one of those cases where security isn't always convenient. The result of this will be that once you sudo for an action within your session your basically running as root for the rest of the session. This opens the door for malicious scripts to being executed with root privileges as well as accidentally doing something to break your system. Your cat could jump on your keyboard and hit the delete key while you have the file browser open with the /etc/ directory selected. –  3dinfluence Jan 6 '10 at 15:22
add comment

4 Answers

up vote 7 down vote accepted

sudo visudo and add the following line:

MYUSERNAME ALL=NOPASSWD: ALL

replacing MYUSERNAME with your username :)

This allows your user account to sudo any command without requiring a password. Note that there are inherent security risks with this though - for example if someone can persuade you to run a script, that script could sudo and do things as root without you noticing. It is convenient though.

share|improve this answer
add comment

You can set timestamp_timeout in the sudoers file (sudo visudo to edit) to a longer value or a negative value (which will make it not expire).

From man sudoers:

timestamp_timeout
                       Number of minutes that can elapse before sudo will ask
                       for a passwd again.  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 timestamp will never expire.
                       This can be used to allow users to create or delete
                       their own timestamps via sudo -v and sudo -k
                       respectively.
share|improve this answer
add comment

You can edit your sudo config file and add the NOPASSWD where appropriate. See the man page (man sudoers) or one of the many online copies (like this one) for more detail.

The config file is usually /etc/sudoers but it is safer to use the visudo command (see man visudo) as this performs some sanity checks before committing the changed file, reducing the chance of accidentally breaking the sudo config.

share|improve this answer
add comment

Set a root password, use 'su' :)

share|improve this answer
    
not sure I follow.. Also I was talking about performing actions in terminal as well as gnome-desktop env - sorry if I wasn't clear about that :) –  sa125 Jan 6 '10 at 8:52
    
gksu used by GNOME does have the ability to switch between 'sudo' and 'su' modes, if you aren't afraid of gconf-editor –  grawity Jan 6 '10 at 10:38
    
Generally a bad habit to work using the root account. sudo is there for a reason. –  pehrs Jan 6 '10 at 11:05
    
sudo is there for a reason, certainly. It's there so you can set the NOPASSWD option and remove all traces of security. Seeing a root prompt should make you think. It's amazing how fast people just type 'sudo' and fail to realize it, it becomes natural and just something the fingers do. sudo is no more secure or no less secure in the real world, if you allow sudo to issue any command. In restricted environments it is useful again perhaps. –  Michael Graff Jan 6 '10 at 11:13
add comment

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.