0

i am new to ubuntu .Using Ubuntu 14.04 LTS.

1 - i want to start my GUI application on ubuntu start up. 2 - the GUI application needs SUDO permission . is there any way i can start my application without entering suso password and run my application.

thanks.

3
  • Could you explain what the GUI application should do and if it has cli options that could possibly do harmful stuff? Sep 6, 2016 at 11:32
  • the gui application should start on start up of ubuntu or reboot ,the user who is going to user the application will not be friendly with the cli. Sep 6, 2016 at 12:20
  • The (safety) issue is that you could add the application to the sudoers file, as one of the answers suggests, but if the application has cli options that could be harfmful, your system is vulanrable. Any code on your system could do harmful things without you knowing it. Sep 6, 2016 at 12:25

2 Answers 2

1

Run the command;

visudo

and add end of line;

username ALL=NOPASSWD: <application>

Try to run after the application of sudo or gksudo.

0

We will have to add a sudoer rule for you. You can do this by adding a sudo snippet in the /etc/sudoers.d directory. For example, for allowing your current user to run /usr/sbin/gparted, issue the following command:

echo $( whoami ) ALL=NOPASSWD: /usr/sbin/gparted | sudo tee /etc/sudoers.d/mysudorule

At this point you can launch sudo -i /usr/sbin/gparted and it will launch with elevated privileges. Since now you can launch the appplication as root, no questions asked, you can go to the Startup Applications program and add a new entry where you fill the command with sudo -i /usr/sbin/gparted. Note that I have not tested this. The -i tells it to fully log in as root.

All examples here use /usr/sbin/gparted because it's tool that requires root, and as such was easy to test. Obviously, you'll need to use your own programs full path.

I know there is a discussion that you should never run sudo for a graphical program, but gksu is not installed by default, and pkexec asks a password regardless of the sudoers configuration. My tests indicate that sudo -i just works fine for graphical applications.

4
  • tried this not working when i do sudo -i "Application path " the terminal displays a empty line . Sep 7, 2016 at 10:24
  • and the GUI app doesn't start? At all? What is the program any way? Sep 7, 2016 at 12:05
  • no the program doesn't start at all, it is a small program written in qt. which just takes input from user like name and age ... Sep 8, 2016 at 13:13
  • So, you basically get a prompt $, an empty line and then a prompt $ again? I really have no idea. I tested this with gparted (because that requires root). I'm sorry, but I fear I can't help you further. Sep 8, 2016 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .