Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to launch a Gnome application with root privileges at login.

I have tried adding a script to launch using update-rc.d myscript.sh defaults.

It looks like the application does launch, but it is no longer there by the time the gnome gui arrives.

How can I do that?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

Running graphical things as root is a bad idea for security but I'm going to assume you know that and that you have exhausted any other methods. You need to do two things:

  1. Allow your user to run the command via sudo without a password by editing /etc/sudoers. You can find a brief explanation here but you're looking for something like this:

    username ALL=(ALL:ALL) NOPASSWD:/path/to/command 
    

    Obviously replace the username and /path/to/command with real values, stick that in there and then try sudo -k /path/to/command (the -k just means it'll ask for your password if it doesn't know any better - it won't ask if your sudoers edit was correct).

  2. Auto-launch your application via the standard "Startup Applications", calling sudo /path/to/command

And that's it.

share|improve this answer
    
If put username ALL=(ALL:ALL) NOPASSWD:/path/to/command in /etc/sudoers, sudo fails with a parse error. ALL= NOPASSWD:/path/to/command seems to parse, but asks me for the password when I run the command. –  benlad Apr 3 '12 at 12:18
    
So, it seems "username ALL=(ALL) NOPASSWD:/path/to/command" must be last in the sudoers file and also "username ALL=(ALL:ALL) NOPASSWD:/path/to/command" does not work with Ubuntu 8.04. –  benlad Apr 3 '12 at 15:29
add comment

You could try to create a custom application launcher (.desktop file) with gksudo <command> as command to run, and add that laucher to the autostart settings (System - Settings - Autostart or Startup). Another way would be to put the .desktop file directly into ~/.config/autostart or (for all users) /etc/xdg/autostart.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.