Cygwin

Before experiencing X
Cygwin/X is installed by selecting the necessary packages from the X11 category with the standard Cygwin installer. Users unsure of what is needed should install all of the X11 components.

Accessing X of your Local Cygwin
You can run the X server and the Window Manager locally and get the X Window GUI environment.

There are various ways you can do this. They are as follows:

MultiWindow Mode
In the multiwindow mode, there is an internal window manager that creates a Windows window to display the X application on the Windows desktop.

X
X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin.


 * 1) Start Cygwin
 * 2) Execute the command,  . (Cygwin/X window comes up)
 * 3) Execute the command,
 * 4) Execute the command,  . (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

startxwin.bat

 * 1) Run startxwin.bat from   folder where your Cygwin is installed. This can be done by double clicking on the batch file. It will bring up an xterm window. If you don't want to go through the hassle of finding this file, you can simply run the startxwin-multiwindow.bat file which should be present on your desktop. Both the scripts are very similar.
 * 2) Execute the command,   in the xterm window. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

startxwin.sh

 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . It'll bring up an xterm window.
 * 3) Execute the command,   in the xterm window. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

startx

 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . It'll bring up an xterm window.
 * 3) Execute the command,   in the xterm window. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

External Local Window Manager
If you want the complete desktop environment, you will have to run a window manager or Linux desktop to send the GUI to your X server. This section is a discussion on this topic.

X
X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin.


 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . (Cygwin/X window comes up)
 * 3) Execute the command,
 * 4) Execute the command,
 * 5) Check your Cygwin/X window. You have got the desktop. :-)

Accessing X of a Remote Box
In the following discussion the following IP addresses and user name have been assumed:-
 * remote_box - IP Address or domain name of remote box
 * my_system - IP Address or domain name of your Windows system
 * user_name - A valid account in the remote box

X11 Forwarding
For some of the methods described in this section, X Forwarding should be enabled in the remote box. Whether this is enabled or not can be found out from the file,  of the remote box.

If there is a line, it means X11 Forwarding is enabled and you can go ahead with the steps below.

If it is,, X11 Forwarding is disabled. You can edit it to enable it. Of course this can be done by the "root" only. If you need X11 Forwarding enabled and you are not the "root" of the box, you'll have to talk to its admin.

MultiWindow Mode
In the multiwindow mode, there is an internal window manager that creates a Windows window to display the X application on your Windows desktop.

X
X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin directory.


 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . (Cygwin/X window comes up)
 * 3) Execute the command,
 * 4) Log in to the remote box with the command,
 * 5) Execute the command,  . (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

For the above method to work, X11 Forwarding should be enabled in the remote box.

startxwin.bat

 * 1) Run startxwin.bat from   folder where your Cygwin is installed. This can be done by double clicking on the batch file. It'll bring up an xterm window. If you don't want to go through the hassle of finding this file, you can simply run the startxwin-multiwindow.bat file which should be present on your desktop. Both the scripts are exactly similar.
 * 2) Execute the command,   to provide remote box access to the X server running on your Cygwin. Alternatively you can execute the command,   to disable access control completely, so that any client can connect to your X server.
 * 3) Log in to the remote box with the command,
 * 4) Execute the command,   on the remote box.
 * 5) Execute the command,   in the xterm window. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

If X11 Forwarding is enabled in the remote box, you can omit step 2 and step 4.

startxwin.sh

 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . It'll bring up an xterm window.
 * 3) Execute the command,   to provide remote box access to the X server running on your Cygwin. Alternatively you can execute the command,   to disable access control completely, so that any client can connect to your X server.
 * 4) Log in to the remote box with the command,
 * 5) Execute the command,   on the remote box.
 * 6) Execute the command,   in the xterm window. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

If X11 Forwarding is enabled in the remote box, you can omit step 3 and step 4.

startx

 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . It'll bring up an xterm window.
 * 3) Execute the command,   to provide remote box access to the X server running on your Cygwin. Alternatively you can execute the command,   to disable access control completely, so that any client can connect to your X server.
 * 4) Log in to the remote box with the command,
 * 5) Execute the command,   on the remote box.
 * 6) Execute the command,   in the xterm window. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

If X11 Forwarding is enabled in the remote box, you can omit step 3 and step 4.

PuTTY

 * 1) Open PuTTY
 * 2) From the Category tree, select "Session" and enter the host details.
 * 3) From the Category tree, select "Connection > SSH > X11" and check the "Enable X11 Forwarding" checkbox.
 * 4) Click "Open" and login.
 * 5) Run an X Server on your Windows machine. There are various ways to do it.
 * 6) Open Cygwin and run.
 * 7) Run   from Windows or open Cygwin and run ,  . An extra xterm opens which might be a pain since you don't need it. (The previous two steps save you from that).
 * 8) Get back to your PuTTY window and execute the command,   (xclock comes up).
 * 9) Check your Cygwin/X window. (You have got the desktop :-))

For this method to work X11 Forwarding should be enabled in the remote box and you should be logging into the remote box using the SSH protocol.

If you want to save yourself from the first four steps, simply add the path of the PuTTY directory to the Windows PATH variable or you can simply put PuTTY.exe in the Windows directory. Henceforth, you can simply execute the command,  from anywhere and then proceed with step 5.

External Remote Window Manager
If you want the complete desktop environment of a remote box, you will have to run a window manager or Linux desktop on the remote box and forward the X output to the X server of your Windows PC so that you can see the GUI on your X server. This section is a discussion on how this can be done.

X
X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin directory.


 * 1) Start Cygwin (The Bash shell comes up)
 * 2) Execute the command,  . (Cygwin/X window comes up)
 * 3) Execute the command,
 * 4) Log in to the remote box with the command,
 * 5) Execute the command,   on the box.
 * 6) Check your Cygwin/X window. You have got the desktop of the remote box. :-)

For the above method to work, X11 Forwarding should be enabled in the remote box.

PuTTY

 * 1) Open PuTTY
 * 2) From the Category tree, select "Session" and enter the host details.
 * 3) From the Category tree, select "Connection > SSH > X11" and check the "Enable X11 Forwarding" checkbox
 * 4) Click "Open" and login.
 * 5) Execute the command, , to run the Cygwin X server on your Windows system.
 * 6) Get back to your PuTTY window and run.
 * 7) Check your Cygwin/X window. (You have got the desktop :-))

For this method to work X11 Forwarding should be enabled in the remote box and you should be logging into the remote box using the SSH protocol.

If you want to save yourself from the first four steps, simply add the path of the PuTTY folder to the Windows PATH variable for once and ever. Henceforth, you can simply execute the command,  from anywhere and then proceed with step 5.

Recipe: Run an X application (on a remote UNIX machine) with a local Windows X Server
- Install Cygwin including the X11 client and Secure Shell SSH.

- Start Cygwin Bash Shell by clicking on the Cygwin icon.

- Start the X Server (This opens another Bash Shell in an X window. $ /usr/X11R6/bin/startx - Allow the remote computer to X Client into your local computer by adding the remoter server to the access control list.  $ xhost +RemoteServerName or IP Address - Use ssh to access the remoter computer. You will be prompted for a UserID and Password.  $ ssh -X +RemoteServerName or IP Address - While on the remote computer execute the program you want in background mode.  $ +ProgramYouWant &

Cygwin Tips

 * Install Cygwin to the default directory, C:\cygwin\ for consistency. You can also make the path longer, for instance to keep multiple versions of Cygwin.
 * When installing, check cygrunsrv to allow for running sshd as a Windows service
 * To use rxvt as the preferred console, create a Windows shortcut with the Target set to C:\cygwin\bin\rxvt.exe --loginShell -sr and Start in set to C:\cygwin\bin.
 * To enlarge the console window and add a title, add -geometry "80x50" -title Cygwin to the Target.
 * To start an SSH session, add -e ssh user@machine.name.com to the Target.
 * To change the default home directory to My Documents on NT-based Windows (NT/2000/XP/2003/Vista), create an environment variable called HOME with value of C:\DOCUME~1\USERNAME\MYDOCU~1 (where USERNAME is your Windows login username).
 * Create an environment variable called SHELL with value of /bin/bash.
 * Make sure c:\cygwin\bin; is added to the Path environment variable.
 * To mount prefix from /cygdrive to / type this command once, mount -s --change-cygdrive-prefix /
 * Or keep cygdrive as is and create mounts (e.g. mount -u C: /C) for every drive.
 * Emacs and vi are the most popular editors but Nano is the easiest to use.
 * Create a file called .bash_profile in the HOME directory containing the following lines:
 * alias dir='ls -lav—color=auto'
 * EDITOR=nano; export EDITOR
 * VISUAL=nano; export VISUAL
 * To use the clear command install the ncurses package (in the lib category)