Ubuntu 18.04 Gnome de.
I made a simple bash script file that flags my next reboot to choose the windows grub entry. For quick rebooting into windows straight from Linux DE.
The problem is I have to use dconf to modify executable files to ask, so I can click run in terminal where it automatically asks for password. Otherwise, just executing the file does nothing, bc it's waiting for a password input.
Is there a way to run a bash script file like this with inherent sudo privileges so it doesn't need to ask for a password?
EDIT (even though it's directed at @waltinator, because comment formatting is atrocious):
So would
/bin/kill
be the location and name of my bash script file? for example, my bash script file is named restart2windows and is located on my desktop:
/home/myusername/Desktop/restart2windows
so I would just need to add this line to /etc/sudoers (I'm still unclear on editing that file, using visudo, and whether I should edit sudoers.d as advised):
myusername mymachinename = NOPASSWD: /home/myusername/Desktop/restart2windows
Would this be correct?
EDIT 2
I tried editing sudoers via visudo:
sudo visudo
and added the line I suggested above, below the commented line:
#includedir /etc/sudoers.d
and then tried to run my bash script file from my desktop, and it did nothing. If I choose to run it in the terminal, the terminal is waiting for a password input.
Here is my bash script file contents, very simple:
#!/bin/bash
sudo grub-reboot 2
sudo reboot now
Found this question here and it appears that I need to add sudo somewhere in there? I'm confused by that answer to that question because his line of code from the OP does not match the OP's.
Edit 3:
I submitted this same post in Ubuntuforums.org as well: https://ubuntuforums.org/showthread.php?t=2434878
myusername mymachinename = NOPASSWD: /home/myusername/Desktop/restart2windows/'sudo grub-reboot 2', /home/myusername/Desktop/restart2windows/'sudo reboot now'
But when I tried to run the script by double clicking and clicking run at the prompt, it did nothing. At the prompt if I choose "run in terminal" the terminal opens and still is asking for a password....
– BingBong Jan 12 '20 at 17:07grub-reboot
command. Not the path to a script on your Desktop. To find the path of a command:which *name of command*
, for example:which grub-reboot
. Will return:/usr/sbin/grub-reboot
. That is the PATH to apply in you sudoers file . The path to the command you intend to use in your script. – da_kingpin Jan 14 '20 at 04:00/boot/grub/grubenv
you can add a parameternext_entry=*number of menu entry to boot
. Have your script assign a vaule to change the parameter to. The vaule would be the menu entry location in your grub boot menu. Nogrub-update
needed. https://askubuntu.com/questions/635205/link-to-restart-from-windows-to-ubuntu. Also check the grub docs https://www.gnu.org/software/grub/manual/grub/grub.html – da_kingpin Jan 16 '20 at 02:42