How to Run Linux Program in Graphical Mode from Windows Xwindow session?

Posted on 2011-10-31
Last Modified: 2012-05-12
I'm trying to run an "runInstaller" program on a new Linux server in Grapical Mode. I always have nightmares trying to run Unix programs in graphical mode. And doesn't help that I'm not a Unix admin or expert.

I have installed xMing and the server isrunning. And I set Putty to use forwarding for my session.

But when I try to run the installer it gives all these errors below. It's
saying the authentication protocol attempted is wrong. I also attached the
putty settings I have.

See attached screen prints.

Can you tell if maybe I just have something setup wrong?? It's driving me crazy!!
 xming putty config1 puttty config2
Question by:matrix0511
    LVL 9

    Expert Comment

    When you launched XMing, did you allow for the server to connect back to you?  I would suggest you use the XMing Luancher and select the option to "Disable Access Control".

    Next, when you connect to your host with Putty, do you "su" to root before you run the GUI app?  

    SSH to your server and run "echo $DISPLAY" to make sure DISPLAY is being set correctly.

    if you do "su" to root, you may need to re-export the DISPLAY variable and copy the x-cookie.


    $ whoami
    $ echo $DISPLAY
    $ su - 
    # export DISPLAY=localhost:10.0
    # cp ~someuser/.Xauthority ~/
    # runInstaller &

    Open in new window


    Author Comment

    @jeremycrussell, so you are saying "instead" of running the Xming Server? Or are you saying...while I still have Xming Server running to run the XLauncher as well?

    Yes, when I login I have to perform the following sudo command to sudo to "oracle" which is the user that owns the installer.

    I have also been running command: export DISPLAY=

    See attached screen prints below. xming Launcher display setting export command sudo command

    Author Comment

    @jeremy, when you say"did you allow for the server to connect back to you?" what did you mean? How can I verify if it "came back to me?"
    LVL 9

    Expert Comment


    Yes, go ahead and kill the running xming (right-click and exit) and then run XLaunch, it simply just configures the XServer, just leave everything default, except on the third pane, check the box for "No Access Control".

    Next, there is an error in your DISPLAY variable.

    Log in, but before you sudo to the oracle user, run "echo $DISPLAY", next sudo to oracle user, and then run "export DISPLAY=<copy from output of previous echo command>", then copy the cookie from the user you logged in as.

    This is kind of what it will look like.

    $ echo $DISPLAY
    $ sudo su - oracle
    [sudo] password  for jburch:
    $ export DISPLAY=localhost:10.0
    $ sudo cp ~jburch/.Xauthority ~/
    $ ./runInstaller -ignoreSysPreReqs &

    The "&" just lets the GUI run in the background so you still have your CLI to do things.. it's optional..

    Author Comment

    Guys, i"m still having problems getting this graphical mode to work. Driving me crazy. If I just login as myself (jburch) and then run the installer the graphic app comes up. But we always sudo to "oracle" user when accessing these servers.

    But when I sudo to oracle (sudo su - oracle) and then try to run the installer it doesn't come up in graphical mode. Why is that??????

    Author Comment

    display error
    LVL 5

    Expert Comment

    Allow X11 forward in putty
    LVL 9

    Expert Comment

    It doesn't look like your Xserver is running now...
    LVL 19

    Accepted Solution

    In image export-command.jpg, you exported your DISPLAY incorrectly - it has an extra "=" sign and reads:

    export DISPLAY=

    That needs to be

    export DISPLAY=

    Try that, and then launch an X app (try something small and fast first like xterm or xeyes to make sure it works & then you can try launching your oracle app)
    LVL 6

    Expert Comment


    Here I have provide some methods for run X windows program as Normal User.
    However both KDE and Gnome come with tools to deal with this problem.
    Method # 1:
    If you are using KDE then use following command at shell prompt:
    kdesu command-name
    $ kdesu xeyes

    Method # 2:
    If you are using Gnome then use following command at shell prompt:
       $ gksuexec
    Method # 3:
    Create runas alias as follows:
     $ alias runas='su -c $@'
    Add above alias to your bash startup script
     $ echo "alias runas='su -c $@'" >> .bash_profile
    now you can use alias as follows to start any x program
     $ runas program-name
     $ runas xeyes

    Method # 4: The old way
    The problem is with two environment variable DISPLAY and XAUTHORITY. You need to setup them correctly to run X windows program as a root user while logged in as a normal user. So how do you fix this problem? Simply set these two variables to point to current logged in users environment variable. Let  assume you are currently login as oracle user.
    Step # 1 Become super-use
      oracle@debian:~$ su -
    Step # 2 Setup variables
      # export DISPLAY=0:0
      # export XAUTHORITY=/home/oracle/.Xauthority
    Step # 3 Execute X program as a root user
      # xeyes

    LVL 9

    Expert Comment

    The previous error you posted was one that looked like it was because the XServer wasn't running on your local PC.  Use XLaunch as I've stated previously to start XMing, remember to mark "No Access Control".

    Then, SSH with Putty to the machine.

    Run the following commands, after the initial login.

    $ echo $DISPLAY

    * Note the output, you may use this later.

    $ sudo su - oracle

    $ export DISPLAY=<output from previously>

    $ sudo cp ~jburch/.Xauthority ~/

       Here, you are copying the X auth cookie that was created when you ssh'd into the machine with Putty and X11 forwarding.  You need to use this cookie, no matter which user you are running as on the box.   You can either set an Environment variable to the path it is, or copy it to the "current" user's directory (default location xclients look).

    Now, you should be able to run any graphical applications as the oracle user, just had not changed users.

    This is the process I use  to have the ability to ssh to a box as a user and su to 'root', and still be able to run graphical programs if needed.   I've added a few simple commands to the default profile of the machines to make this process automatic, works out great.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
    I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension ( This reminded me of questions tha…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now