 <p>First things first: Why are you trying to run a graphical application with superuser privileges? This is in general a a bad idea.</p> <hr> <p>X11 implements various authentication mechanisms to prevent users which are not part of the login session to access the X server. This is implemented not though Unix file permissions, but through protocol authentication. So even if you're root, you can not talk to the X server, without jumping through a few hoops. In particular every client needs access to the Xauthority cookies. Those are stored by default in <code>${HOME}/.Xauthority</code> but can be defined to be fetched from a different location using the <code>XAUTHORITY</code>environment variable.</p> <p>So to pass that through sudo you'd set XAUTHORITY to point to your login session user's <code>~/.Xauthority</code> and then call sudo with environment preserving option.</p> <pre><code>export XAUTHORITY="${HOME}/.Xauthority" sudo -E ./idea.sh </code></pre> <p>Or you could set the XAUTHORITY environment after sudo. Another, much more blunt options is to simply punch a hole into authentication that allows all clients running locally to access the X server. However this is a bad idea, because then <em>every</em> user on your system could run a keylogger or otherwise mess with your session (for example preventing the screen locker to work). You can punch that hole with <code>xhost +si:localuser</code> but you really should not do it.</p>