Hari's Corner

Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and then

Simple way to run X apps as root in Linux

Filed under: Tutorials and HOWTOs by Hari
Posted on Wed, Jan 28, 2009 at 20:44 IST (last updated: Fri, Jan 30, 2009 @ 07:27 IST)

There's a very simple trick to run X apps as root. We know the usual problem when you try to run an X application from a root terminal; we get a message similar to the one below:
[application]: cannot connect to X server :0.0

So instead of jumping all kinds of hoops, just run the application by calling kdesu (if you're running KDE), gksu or sux (if you're running GNOME/GTK) from a non-root terminal (for instance, to run the KDE package manager as root):
$kdesu kpackage

This is a very simple trick and does not require any hacking into your X or shell configuration files, and worth remembering if you ever need to run any X window application as root when you are logged in as a normal user.

6 comment(s)

  1. Another simple way is to use the xhost command just in case for those that don't have KDE installed. ;)

    Comment by drew (visitor) on Sat, Jan 31, 2009 @ 11:13 IST #
  2. Oh, sorry, you do have to export the display as well so you don't get the silly error.

    Comment by drew (visitor) on Sat, Jan 31, 2009 @ 11:18 IST #
  3. There is another way, slightly more involved but just as straightforward. Since I found this on Alien Bob's wiki, I'll link to it rather than copy/paste it: http://alien.slackbook.org/dokuwiki/doku.php?id=linux:kernelbuilding&s[]=kernel

    However, tips like this are what the internet is for, so definitely keep em coming :)

    Comment by ray (visitor) on Sun, Feb 1, 2009 @ 18:10 IST #
  4. Alien Bob needs to compile his kernels like a real man and not use xconfig. The ncurses (text based menu) way is how real Linux users compile their kernels. ;)

    Comment by drew (visitor) on Tue, Feb 3, 2009 @ 00:04 IST #
  5. But the xconfig interface is so nice to navigate around ;-)

    Ncurses is good, but can be a pain when you forget which menu option you're working in. A few times I've dropped out of some hard drive config options and then continually returned to the same options because I was convinced I was elsewhere in the menu.

    Comment by ray (visitor) on Tue, Feb 3, 2009 @ 14:13 IST #
  6. Hey Ray and Drew. Sorry for the late response. I've been away for a few days and without any computer or internet access. :)

    Comment by Hari (blog owner) on Fri, Feb 6, 2009 @ 09:14 IST #

Comments closed

The blog owner has closed further commenting on this entry.