1. 2010
    Aug
    08

    Running GUI apps as root

    I just ran into a funny problem where I was unable to run GUI apps as root, although I had no trouble using KDE and its applications as my normal non-root user. I’d get various sorts of error messages, like “unable to open display :0” or “cannot connect to X server :0” depending on how I tried to run the program (with su, sudo, etc.). Turns out the solution was to do this:

    xhost +si:localuser:root
    

    xhost is the program that lets you alter the access control list that governs connections to the X server. When invoked with no arguments, it prints out the current list, which in my case was

    INET:acetylene09
    SI:localuser:diazona
    

    acetylene09 is the hostname of my computer. You’d think that having the hostname in the list would be enough to allow connections from it, but no, X is fickle. I had to add an explicit directive to allow connections being made by root, in addition to the one that was already there to allow connections from my regular username.