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 tried to submit an app to the Ubuntu Software Centre but it was rejected because you needed to put in the admin password to use it. I need to grant root privileges to the app for it to function so I used sudo. But they said I can't use sudo in my app. How can I give it root privileges?

share|improve this question
Is this a GUI-based app or is it CLI only? What language is it coded? – Takkat May 31 '13 at 6:20
Command Line and it's in python. – Brady Jun 1 '13 at 4:02

You need to use the PolicyKit APIs to request the escalation of privileges. In general, you should only do so when it's absolutely necessary, and not run the application with escalated privileges at all times.

It's worth noting that if you only need root privileges on startup, you can and should start up as root, but then drop to an unprivileged user. If you're operating as a user-facing program, this probably means the user that ran the program; if this means a daemon, like an httpd or sshd, it probably means an incredibly locked-down user that's created specifically for your program to run under.

Also, there are graphical frontends to sudo called gksudo and kdsudo for GNOME and KDE, respectively. If someone recommends that you use these, don't. Be aware that these programs are deprecated in favor of PolicyKit, are not installed by default, and will probably get your app rejected.

share|improve this answer
Can you please explain to me how to PolicyKit to execute the following line of code without using sudo. 'sudo apt-get clean' – Brady May 24 '13 at 15:28
I'm not sure why you're doing things with apt, but you should look at using the aptdaemon APIs via dbus, for performing actions with apt. – dobey May 24 '13 at 16:49
It's a clean-up application. Isn't there a way to give the program permanent root access. – Brady May 24 '13 at 19:36
As if it were owned by the system... – Brady May 26 '13 at 14:52

Your app might not be permitted at all. According to the Ubuntu wiki, the App Review Board will reject applications that touch system files:

Your application appears to touch system files as part of its operation, however we do not allow apps to do this as part of a security policy for For these applications, we recommend that you follow the steps on for submitting your package to Debian or Ubuntu.

A cleanup app would be touching system files.

While this guideline only applies to open-source apps (the policy for proprietary apps is not published), I imagine similar rules apply to proprietary apps.

If your app is open-source, you can still get it into the Software Center by packaging it and submitting it to the main Ubuntu or Debian repositories.

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.