I'm trying to run a shell script on my Linux desktop (Tuxedo OS) that allows me to reboot directly into Windows. The script uses the commands `sudo grub-reboot '2'` followed by `reboot`. When I double-click the .sh file, it reboots, but it doesn't set the grub boot to '2', so I end up back in Linux instead of Windows. Currently, the only way I've found to make it work is by right-clicking the script, selecting 'Run in console', entering my password, and then rebooting. Is there a way to configure it so that I can double-click the script and still have the sudo command executed?
3 Answers
You can execute commands in a new terminal window using a slightly different approach. For instance, you can use `konsole --hold -e bash --rcfile <(echo "./your_script.sh; exit") &` to run your script in a new terminal. This way, even with sudo, you'll be prompted for your password in that new window. Using .desktop files might also be an option if you're looking for something more elaborate.
Just a heads up, Tuxedo OS is based on Debian, and your request might clash with certain security measures in Linux. The system is designed to prevent unauthorized reboots or changes in GRUB directly from a running session to avoid potential exploits. Just be aware that this limitation is part of Linux’s security model, so finding a way to bypass it may create vulnerabilities.
You might want to try using `run0` instead of `sudo` if Tuxedo OS is systemd-based. This could bring up a GUI prompt for your password, which might be handy. Alternatively, `gksu` could also work, but keep in mind that it's specific to GTK environments.
I appreciate the advice! I'm always learning something new thanks to you guys.

Thanks for the tips! I wasn't aware that those options existed between different distros. I tried both `run0` and `gksu`, but no luck yet. I'll keep searching for other alternatives!