A simple trick to disable the
sudopassword prompts on
Ubuntu(I have tested this on
Ubuntu 9.10 Karmic Koala). A word of caution, be aware that by doing this you are sacrificing the security that
You basically need to edit the
/etc/sudoersfile. This file cannot be changed by any user. You need to sign in as
rootand then use the
visudocommand to start editing the file.
user@machine:~$ sudo su[sudo] password for user:root@machine:/home/user# visudo
In this file, right at the bottom you will find a line:
%admin ALL=(ALL) ALL
Replace it with:
%admin ALL=NOPASSWD: ALL
This will disable the requirement to enter the password every time you run a
sudocommand. Save and close (
ESC, :wq, ENTER)
So you can now run a command like
sudo rebootwithout having to enter the password:
user@machine:~$ sudo rebootBroadcast message from user@machine(/dev/pts/0) at 11:17 ...The system is going down for reboot NOW!
Again, be careful and know what you are doing. Also, it might be a good idea to make a copy of your
/etc/sudoersfile before your make any changes to it.
One way to use this trick could be in a scenario where you want to run a
sudocommand through a script and do not want to use the
-Soption allows you to provide the password from the script itself; this can be dangerous if someone gets access to your script)