A simple trick to disable the
sudo
password 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 sudo
provides. You basically need to edit the
/etc/sudoers
file. This file cannot be changed by any user. You need to sign in as root
and then use the visudo
command 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
sudo
command. Save and close (ESC, :wq, ENTER
)So you can now run a command like
sudo reboot
without having to enter the password:user@machine:~$ sudo reboot
Broadcast 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/sudoers
file before your make any changes to it.One way to use this trick could be in a scenario where you want to run a
sudo
command through a script and do not want to use the -S
option of sudo
(-S
option allows you to provide the password from the script itself; this can be dangerous if someone gets access to your script)