Installing Cygwin and Cygwin/X

First go to the main website and install cygwin. You do it by running the script cygwin.exe found here. The same Windows executable needs to be run every time you wish to add, remove, or update a package.

For the initial installation, include all the core packages and also the xinit package. The latter is essential as it contains Cygwin/X (no xinit, no graphical applications!) You may also want to include some of the packages you will want to install later on in the initial installation. However, the initial installation takes quite long as it is so you may want to leave those for later.

Once Cygwin and Cygwin/X have been installed, you will  have two new folders in your Windows “Start” menu: “Cygwin” containin the executable “Cygwin64 Terminal” and “Cygwin-X” containing “User script” and “XWin Server”.

Running the Cygwin terminal and working with files and directories

To run non-graphical applications, e.g. “ls”, “cd”, “mv”, etc. you just need to run “Cygwin64 Terminal”. When navigating through files and directories, you must remember that the notations for paths used within Cygwin are as in Linux, i.e. “/” is the root directory, “~” is your home directory, etc. Also, note that Cygwin is all contained within a single folder in your Windows machine, though there is a directory called “/cydrive” within Cygwin that allows you to access the rest of the Windows system. The following table explains this better and gives further information:

Executing with the Cygwin terminal … … is equivalent to the following in the Windows Command Prompt:
cd / C:
cd C:\cygwin64
cd ~ C:
cd C:\cygwin64\home\<username>
cd /cygdrive/c C:
cd C:\
cd /cygdrive/c/Users/<username> C:
cd C:\Users\<username>

 

So as can be seen it is possible to access any directory from either Cygwin or the regular Windows Command Prompt.

It is possible to set up symbolic links to make key Windows directories easy to reach from within Cygwin, e.g. running within the Cygwin terminal the commands

ln -s /cygrdive/c/Users/<username> ~/winhome

will create a link allowing access to the user’s Windows home directory from within the user’s home directory in Cygwin.

Using X-Windows applications

The Cygwin-X menu within the Windows Start menu contains two executables: “User script” will launch a large windows within which you will have a running X-windows environment, with a basic Window manager and no desktop enviornment. More sophisticated Window Managers and Desktops are available as packages to be installed later if you want.

Perhaps more useful is the other exectuable, XWin Server. This will run an X-Windows server on the background. Two icons will appear in the notifications section of your task-bar (usually ont he bottom-right of your screen, where the notificatios about USB devices, etc. normally appear). One of these icons just tells you that the X-server is running. The other icon gives you, when you click on it, a menu to launch various programs that you have installed. Under “System tools” within that menu you will find the option to launch the Cygwin terminal (the same that you can laucnh directly from the Start menu, under “Cygwin64 terminal”) and also an xterminal. From those terminals you can launch any graphical application (or you can also launch them from the said menu). If you launch an application form the terminal, remember to put an ampersand “&” after the command, before you hit “RETURN”, to make sure the terminal window can still be used to launch other applications. I find it very useful to configure the Windows task bar so that the icon for this Cygwin/X menu is always show in the task bar without the need to click on the “rotated >” symbol on the tas bar (right-click on the task bar, settings, notification area, “select which icons appear on the taskbar”).

It is useful to have the X server configured to boot on start up. This way the X server icon will always be on the task bar ready to launch Cygwin applications. On the Windows Start Menu, go to “Cygwin-X”, right-click on “X-win Server”, select “Open Field Location” (may be under “More”), and then drag its icon, while pressing “ALT” (so as to create a link), to the folder “C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup”. That’s it.

X-Windows from a non-graphical terminal

You can also launch the X-server and graphical applications from the regular Cygwin terminal. We offer that information here just for completeness (it is really not necessary to do this).

If you are already running the X-server as explained above and launch the Cygwin terminal from the menu provided by the Cygwin/X icon on the task bar, then your Cygwin terminal will work just as well as an xterm to launch applications from. If, on the other hand, you have started the Cygwin terminal from Start –> Cygwin –> Cygwin64 Terminal, then even if the server is running it will not know about it. You can let it know about it by the command “export DISPLAY=:0.0” e.g. to launch nedit

export DISPLAY=:0.0
nedit

This will remember the display you set for future application launches. Alternatively you can just write

DISPLAY=:0.0 nedit

and it will jsut be a one-off. It is also possible to write the line “export DISPLAY=:0.0” into ~/.bashrc and then all terminals will know about where the display is.

None of that will work, of course, if the X-server is not running. If you want to do the whole thing from the Cygwin terminal you write the following commands:

XWin :0 -clipboard -multiwindow &
export DISPLAY=:0.0