Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm not trying to delete my password or anything. I just want ubuntu to remember my password after I login as an admin user and use that when installing/removing software or running sudo commands. The non-admin users should be prompt for the admin password though. Is there a way to do that and if so why doesn't ubuntu do that as default?

share|improve this question

2 Answers 2

There's no such thing as "an admin password" in Ubuntu. Any user can elevate his privileges by using sudo as long as that is available to him. And by default sudo requires you to re-authenticate for security reasons. This is a sane default for this reasons as it fits with the "secure by default" policy.

However, it does remember it for a short period of time. Here's a question on how: How does sudo remember you already entered root's password?

Several options to go from here:

  • Passwordless sudo

    From the manpage of sudoers(5):

    By default, sudo requires that a user authenticate him or herself before running a command. This behavior can be modified via the NOPASSWD tag.

    Just change the lines in /etc/sudoers to include this. E.g.:

    %admin  ALL=(ALL) ALL
    %sudo   ALL=(ALL:ALL) ALL
    

    becomes

    %admin  ALL=(ALL) NOPASSWD: ALL
    %sudo   ALL=(ALL:ALL) NOPASSWD: ALL
    
  • Extend timeout

    By default sudo will "remember" your password to elevate your privileges again for fifteen minutes. You can extend this to a much longer time, let's say a day. Do note that this is not unlocked on login, but only triggered the first time you are elevating your privileges.

    To extend this, edit the /etc/sudoers file and locate the line

    Defaults        env_reset
    

    and append ,timestamp_timeout=1440 to it so it becomes

    Defaults        env_reset,timestamp_timeout=1440
    

    Alternatively, use -1 (a negative value) to have a really indefinite timeout. Read more about this on the Ubuntu Community wiki: RootSudoTimeout.

Important note! Editing the /etc/sudoers file should be done with great care. Incorrect syntax will result in a system on which you are probably not be able to elevate your privileges again and you'll have to perform a rather complicated password recovery. To edit it safely, use the sudo visudo command in the terminal. It will not directly write to the file, but only when you exit and save it and the syntax is correct. This will prevent a lot of trouble.

share|improve this answer
    
I'd like to just point out that there is a reason for why the password prompt is there, and that by disabling it, you're effectively removing critical parts of the security layer - and that this shouldn't be done on any kind of production machine. –  sakjur Apr 6 '13 at 14:44
    
What I wanted was to be asked for password at only login screen and never after that point. You are saying it is not possible? –  Serhat Apr 6 '13 at 15:57
    
maybe possible, but certainly not adviseable –  pfeiffep Apr 6 '13 at 16:28

In your system settings - little gear icon in right top corner - you can open Users. Click on the user you want to modify for the passwordless login. In the settings dialogue you can change the setting automatic login.

share|improve this answer
3  
I don't think this is a login setting to change as I think OP is asking for a way to have an indefinite sudo password remember time. –  gertvdijk Apr 6 '13 at 14:08
    
But it's this answer that other people may have looked for, when searching Google for ubuntu automatic login ;) It's this answer that I was looking for, at any rate. –  Victor Piousbox May 6 at 3:02

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.