Avoid Password Prompt When Executing The Sudo Command

If you have experience of working on the command line in Ubuntu then you are probably familiar with the sudo command, whenever you run the sudo command as a non root user then the system prompts you to enter the administrator’s password. This is a seriously annoying process.

Here is the simple tip which gets rid of this password prompt, follow these tweaks if you have a situation where you don’t want to enter the root password while running the sudo command as a non-root user.

You will need to modify a system file in this regard, so first open the terminal and run the following command to become the root user.

su

Once you are done,  go through the following steps to get rid of this annoying password prompt for the sudo command.

  • Assign the permissions to the sudoers file, by running the following command:

chmod 740 /etc/sudoers

  • Now edit the /etc/sudoers file and add the following line at the end of this file. (You can run gedit /etc/sudoers command to open the file for editing). Alternatively the best and secure way to edit the /etc/sudoers file is via visudo utility. You will need to run this utility from the command line, go to the /etc directory and run the command visudo. You will find the /etc/sudeors file opened. Add the lines as mentioned blow and then save the file by pressing ZZ or typing :wq! if you are in the command mode.

%admin ALL=(ALL) NOPASSWD: NOPASSWD: ALL

Sudeors

That’s it, now you will be able to run the sudo command as a non root user without being prompted to enter the password. It will literally save you time and increase productivity.

Update: Instead of using the Gedit to edit the sensitive sudeors file, we have included the visudo method which is more secure. Thanks to all commenters who pointed out the flaws.

  • Share this article!

    • Digg this!
    • Bookmark on Reddit
    • Bookmark at Delicious
    • Stumble this!
    • Share this post at Facebook
    • Tweet this!
    • Share on Yahoo! Buzz
    • Add AddictiveTips to your Technorati favorites
    • Share on Friendfeed
This entry was posted in Ubuntu Linux and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

17 Comments

  1. Bobdole
    Posted November 26, 2009 at 12:48 pm | Permalink

    Isn't this a huge security risk?

    This basically nullifies any and all security built into linux. If everyone did this, there would be viruses for linux. There's a very good reason it asks for a password in the first place.

  2. sparky
    Posted November 26, 2009 at 11:16 pm | Permalink

    So much for 'bloggers' who understand the purpose of SuDu. Idiots.

  3. boo
    Posted November 27, 2009 at 12:35 am | Permalink

    I think it's a good article, although I would disagree doing so..
    But anyway it's a good-to-know for Linux users eh..

  4. Nakodari
    Posted November 27, 2009 at 3:00 am | Permalink

    Agreed. But if you want to disable it for a short period of time, then you can disable it and then later re-enable it.

    We do not recommend disabling it, but just wanted every linux user to know that this is possible.

  5. sparky
    Posted November 27, 2009 at 4:16 am | Permalink

    So much for 'bloggers' who understand the purpose of SuDu. Idiots.

  6. boo
    Posted November 27, 2009 at 5:35 am | Permalink

    I think it's a good article, although I would disagree doing so..
    But anyway it's a good-to-know for Linux users eh..

  7. Nakodari
    Posted November 27, 2009 at 8:00 am | Permalink

    Agreed. But if you want to disable it for a short period of time, then you can disable it and then later re-enable it.

    We do not recommend disabling it, but just wanted every linux user to know that this is possible.

  8. sparky
    Posted November 27, 2009 at 9:16 am | Permalink

    So much for 'bloggers' who understand the purpose of SuDu. Idiots.

  9. boo
    Posted November 27, 2009 at 10:35 am | Permalink

    I think it's a good article, although I would disagree doing so..
    But anyway it's a good-to-know for Linux users eh..

  10. Nakodari
    Posted November 27, 2009 at 1:00 pm | Permalink

    Agreed. But if you want to disable it for a short period of time, then you can disable it and then later re-enable it.

    We do not recommend disabling it, but just wanted every linux user to know that this is possible.

  11. Posted January 2, 2010 at 6:50 am | Permalink

    never, never, never, never, EVER edit /etc/sudoers with anything other than visudo!!!

  12. Donny
    Posted January 2, 2010 at 7:35 am | Permalink

    “This is a seriously annoying process.”

    “It will literally save you time and increase productivity.”

    Are you a system administrator or an average desktop user? The former usually uses su instead of sudo and it's really not common for the latter to need administrative privileges as often as those two sentences suggest.

  13. Posted January 2, 2010 at 9:01 am | Permalink

    Poopieheads!

  14. Posted January 2, 2010 at 7:28 pm | Permalink

    I am a Linux Newbie, but from what i know about the Linux structure & its way of functioning: 'THIS IS A VERY DANGEROUS & RISKY TRICK'
    Rather this is the easiest way to compromise your Operating System & should be never done. A average user should use sudo only & only when extremely necessary.

    NEVER EVER USE THIS TRICK.
    If anyone doesn't like to type passwords he should use Windows & not Linux.

  15. 726b
    Posted January 2, 2010 at 7:32 pm | Permalink

    I suggest everyone who read this to take a loot at http://blog.lynxworks.eu/20100102/ubuntu-spot-t...

  16. Adam Stovicek
    Posted January 3, 2010 at 11:04 am | Permalink

    If it's a matter of convenience, wouldn't it make more sense to increase the password timeout than disabling completely? Ubuntu is installed with a default of 15 minutes and I rarely find myself having to enter the password more than once or twice while administering a system. And at times when convenience trumps security, I'll “root up” with sudo -i or su as was stated in the post above. There should be no reason to disable a security reason over convenience.

  17. Posted January 5, 2010 at 11:38 am | Permalink

    “su”? On Ubuntu?

    *giggle*

3 Trackbacks

  1. [...] Personalmente no lo recomiendo, pero si aún quieres hacerlo sigue los siguientes pasos: [...]

  2. By Ubuntu spot the difference | Lynx Blog on January 2, 2010 at 6:21 am

    [...] Here is the post in question is a cracker. I can think of several things that are wrong with it but see what you can come up with. Here’s a starting hint – man visudo. Share and Enjoy: [...]

  3. By Ubuntu spot the difference - Lynx Blog on June 7, 2010 at 10:24 pm

    [...] spot the difference, see how many things you can spot that are wrong with it and post them here.Here is the post in question and it is a cracker. I can think of several things that are wrong with it but see what you can come [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


More in Ubuntu Linux,Windows (5 of 5 articles)