how do I make a desktop shortcut to run a sudo command?

It is best if the password is typed by the person with sudo/root privileges.

So, not really addressing what the OP wants, this is my way.

1 - Create a .desktop file with a text editor (updater-upgrader.desktop) and copy the following into it, I have it as /home/username/Desktop/updater-upgrader.desktop

#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=updater-upgrader
Name[en_US]updater-upgrader
Exec=lxterminal -e sudo /home/username/scripts/updater-upgrader.sh
Comment[en_US]=

2 - Create a script file (updater-upgrader.sh) with the following text, save and make it executable, I have it as /home/username/scripts/updater-upgrader.sh

#!/bin/bash # # test if we are running with sudo if [ id -u -ne 0 ] then echo "not called with sudo" exit fi # # use red color for highlighting text red="\x1b[31;01m" # reset text colors to terminal default reset="\x1b[39;49;00m" # echo -e "$red********************************************************$reset" echo "Updater" printf "Type$red YES$reset <enter> to continue updating : $red" read yes printf $reset if [ "$yes" != "YES" ] then exit fi echo -e "$red*****************************************************$reset" echo "apt-get update" apt-get update echo -e "$red*****************************************************$reset" #echo "apt-get upgrade --force-yes" echo -e "$red*****************************************************$reset" echo "apt-get install -f" apt-get install -f echo -e "$red*****************************************************$reset" echo "apt-get -y autoremove" apt-get -y autoremove echo -e "$red********************************************************$reset" echo printf "Type$red YES$reset <enter> to reboot : $red" read yes printf $reset if [ "$yes" == "YES" ] then shutdown -r now fi exit 0

Double-click updater-upgrader in the Desktop (the .desktop part will not show), enter the password and start the process.

As always, no strings attached, use at your own risk, modify it completely or completely ignore this suggestion.

/r/Lubuntu Thread