Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've written a custom GNOME panel applet in Python that needs to write to some root-owned files. Is there a way to make it start with root privileges without using suid?

share|improve this question
Can't you just launch it gksudo and add a rule into /etc/sudoers to not request for a password ? – João Pinto Feb 25 '11 at 13:19
up vote 6 down vote accepted

You can do this with PolicyKit.

share|improve this answer

Better solution: do not run whole applet with root permissions. Put everything possible to applet which is running with normal user permissions. Create separate program that modifies necessary files, and run that through sudo (or suid).

For sudoers configuration, run visudo. Try something like

yourusername ALL=(ALL) NOPASSWD: /usr/local/bin/

To allow running specific commands with root permissions.

Another way: add file acl to those root owned files to allow changes by your user.

See man setfacl for more information (from package acl).

share|improve this answer

You should separate the procedures that require root access into a separate python program and launch that with gksudo.

I asked a similar question on Stack Overflow.

share|improve this answer

Your Answer


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.