How to use Cygwin X server for local and remote

Cygwin not only provides most of the Linux programs and shells, it also comes with a builtin X server called Cygwin/X. This is great if you want to run Cygwin GUI applications locally or over SSH from a remote computer.

Install Cygwin/X

  • Install Cygwin, if you do not already have it.
  • Use the Cygwin setup program and install the xorg-server and xinit packages. The first one is the X server and the second installs a lot of scripts and programs that enable you to start the server and use it.
  • Install the xeyes package. This is a small X application that we will use for testing X.

Use Cygwin/X for local apps

  • Kill the xinit, XWin and other X server processes if they are running and close all your Cygwin windows. Open a new Cygwin window.
  • Set the DISPLAY environment variable:
$ export DISPLAY=:0.0
  • startx: If you run startx, you get X server opening a X window with XTerm running inside it. From here on, you can open X apps by running them from that XTerm. You can try by running xeyes inside that XTerm. Once you kill this X window, your X server is closed.

  • startxwin: If you run startxwin, you get X server running, but no windows are displayed. You can now open another Cygwin window and can invoke individual X apps there and they will be displayed in individual windows. You can try by running xeyes from the Cygwin shell. This is called the multiwindow mode.

Use Cygwin/X for remote apps

  • Follow all the steps shown above for local X apps. Make sure you have killed the earlier X server processes, set the DISPLAY environment variable locally and run startxwin. Make sure local X apps can display a window to the Cygwin/X server.
  • SSH to the remote computer running Linux using ssh on Cygwin or PuTTY. Make sure you have X11 Forwarding enabled for this SSH session. This is usually done by specifying -X (untrusted forwarding) or -Y (trusted forwarding) or setting the corresponding X11 Forwarding option in your SSH config file.
  • Check the DISPLAY on the remote computer. It should be set to some value like shown below:
$ echo $DISPLAY

If DISPLAY is empty, then either you did not set DISPLAY locally, did not cleanly restarted a X server locally or there was a problem with SSH X11 Forwarding. Please diagnose.

  • Run the xeyes program from the remote computer. It should display in a window on your local machine. Your Cygwin/X server is working! You can now run GUI/X apps from the remote computer and display them locally. Beware that they will be slow to display and refresh.

Tried with: Cygwin 2.10.0 and Windows 10


One thought on “How to use Cygwin X server for local and remote

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s