How to make .desktop entry launch an executable app that normally requires 'sudo' command via terminal?

Hi,

If an executable application requires the terminal with ‘sudo’ to launch, how do you make a .desktop entry file launch the app without the need for the terminal and password?

I’m able to create .desktop entries no problem with any other applications, but in this specific context I am unable to figure it out. I can set the ‘terminal’ string in the .desktop entry to true, but then it just launches the terminal when I click the applications icon and I must enter my superuser password anyway. I want to bypass this and have it launch the application just by double-clicking the icon.

Anyone have knowledge on this?

If you use pkexec instead of sudo, you can avoid the terminal and will get a graphical password prompt.

If you want to run the application as root with no password at all you can add a drop-in file in /etc/sudoers.d/ so sudo doesn’t ask for a password.

Something like:

%wheel ALL=(ALL:ALL) NOPASSWD: /path/to/my/application

Just be aware that there is risk to running an application as root without a password. Especially if that application can run arbitrary commands.

3 Likes

This did the trick.

Brother, you are LEGEND

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.