Is there a way to store your user password in a script, such that any command in the script which requires sudo will run without prompting? Obviously security is not a concern here.
Here is one way to run a user script which requires a root password.
Open the sudoers file vis visudo. Note - to edit the sudoers file the system uses vi. It can be confusing to new users. When it opens, select Edit. To insert a line, press I. Then type what you want. After you finish typing, hit the ESC key to get out of the editing mode. Then type :w to write/save your input. To exit, type :q
Enter the following text (example is for username dave and script /home/dave/Desktop/testscript.sh)Code:sudo visudo
This script will now run without having to input the root password.Code:dave ALL= (root) NOPASSWD: /home/dave/Desktop/testscript.sh
I tried that, but it is not actually the script that requires sudo, rather one of the lines in the script. The entire script is
After editing sudoers for the script name, I tried it with and without sudo before the command. With sudo I get prompted for the p/w. Without I get the error I would expect to get if I ran it without sudo. I tried adding /usr/bin/vmware to the sudoers file instead, but I got the same error without sudo, and a different one with.Code:#! /bin/sh sudo /usr/bin/vmware
BTW, when I ran the 'sudo visudo' command, it opened nano, not vi.
There are two mistakes one can make along the road to truth...not going all the way, and not starting.
--Prince Gautama Siddharta
#ubuntuforums web interface