Difference between revisions of "Cygwin"

From assela Pathirana
Jump to navigationJump to search
Line 1: Line 1:
===What is Cygwin===
#Redirect{}
{{box|It is expected that you are a little bit familier with [[wikipedia:Unix|Unix]] or [[wikipedia:Linux|Linux]] systems. If not, please read [[UNIX_tutorial|this tutorial]] first.}}
For Windows users: Cygwin is the easiest way to test the waters of  [[wikipedia:UNIX|UNIX]] while in the safety of your windows environment. You can learn a bit of UNIX easily, or  better still can use it to do certain useful things easier than with normal windows software. See this [[A_Productive_Desktop_Environment_for_Scientists_and_Engineers |article]] for a couple of example situations.
 
(For [[wikipedia:Linux|Linux]] or [[wikipedia:Unix|Unix]] users: Don't bother.)
 
===Installation===
Installing Cygwin is rather easy, mainly due to the excellent installation program. You need a working internet connection. First visit [http://www.cygwin.com/ Cygwin website] and download [http://www.cygwin.com/setup.exe setup.exe] program. This is a tiny program under 300 kB. Cygwin [http://www.cygwin.com/cygwin-ug-net/setup-net.html help pages] have extensive information on how to use this little program to install Cygwin. Only some important points are given below. Start by double clicking on the setup.exe program.
#Select 'Download and Install from the Internet'
#Go mostly with the defaults. Particularly
#* Default text file type should be 'UNIX'.
#Select packages:
#* 'Base' and some others are automatically selected, don't deselect them. Additionally, select 'Devel'. Don't bother with the others at this stage, for it is rather easy to add packages as you need them later.
 
{{box|When file/folder names have spaces, we should use the forward slash to 'escape' them in UNIX.}}
After the installation is finished do the following:
# Copy  the setup.exe file to your installation directory (usually C:\Cygwin). We can find it there easily, if we need to download additional packages later.
# It is possible to use Cygwin within the Windows '[[wikipedia:cmd.exe|cmd.exe]]' (the 'dos prompt'), it is much easier and fun to use one of the x-windows based terminals. My choice is the [[wikipedia:xterm|xterm]]. However, with modern high resolution displays, x-term's default font size can be hard to read. To overcome this, one can start xterm with the following command: <nowiki>
</nowiki><pre><nowiki>xterm.exe -fn '*18*'</nowiki></pre> It sets the font size to 'one of those fonts of 18point size'.
# It is possible to 'map' the whole windows file system to be accessed within Cygwin's Unix shell.
#* Folowing commands will mount the drive c: within Cygwin. <nowiki>
</nowiki><pre><nowiki>
mkdir /c
mount c: /c
</nowiki></pre>
#* Then it is possible to navigate the windows file system in c: within the dos shell. For example: <nowiki>
</nowiki><pre><nowiki>cd /c/Documents\ and\ Settings/yourstruely/Desktop/</nowiki></pre> will change directory to your desktop. (Replace yourstruely with your user name, of course.)
#Now set some windows environment variables to make our lives with cygwin easier. (Control Panel->System->Advanced->Environment variables)
#* '''Append''' the following to the '''Path''' variable <nowiki>
</nowiki><pre><nowiki>C:\cygwin\usr\X11R6\bin;C:\cygwin\bin</nowiki></pre>
#* Add a new variable called '''DISPLAY''' and set the value as follows<nowiki>
</nowiki><pre><nowiki>localhost:0.0</nowiki></pre>.
#There is a file named startxwin.bat in the folder C:\cygwin\usr\X11R6\bin\ copy it to c:\cygwin (Cygwin root). Then rename the new file as xterm.bat. Edit the line <nowiki>
</nowiki><pre><nowiki>%RUN% xterm -e  /usr/bin/bash -l</nowiki></pre> to be like <nowiki>
</nowiki><pre><nowiki>%RUN% xterm -fn '*18*' -e  /usr/bin/bash -l</nowiki></pre>
#Create a windows shortcut targeting C:\cygwin\xterm.bat
# Now double clicking on the shortcut should open a Cygwin window with large fonts. [[Image:xterm.onwindows.jpg|thumb|{{wp|X-terminal}} with large fonts, on windows desktop.]]
 
;Note: In the future sections we shall be using the cygwin shell opened using this method.
 
==A good text editor==
{{hbox|There is more information on text editing and editors [[A Productive Desktop Environment for Scientists and Engineers - Part III#Get a good text editor|here]]. }}
Try not to use the windows notepad to edit data or script files you use in cygwin. Instead use the [[wikipedia:nedit|nedit]] (called [[wikipedia:nirvana editor|nirvana editor]]) that comes with cygwin. If it is not there, simply install it following the section below.
 
Nedit can be called from the cygwin bash shell: <nowiki>
</nowiki><pre><nowiki>
$ nedit &
</nowiki></pre>
 
 
===Now what?===
There are hundreds of very useful things that one can when a Unix shell. Now that it is there, you may want to read [[A_Productive_Desktop_Environment_for_Scientists_and_Engineers| this article]] which list some uses of the Cygwin for useful activities like simple data processing.
 
 
 
===Adding programs===
Cygwin has a wealth of packages that can be useful for different situations. Installing the whole darn thing is not the way to go. It can certainly be done, but, is redundant and can be an immense waste of time to download and install them all. Instead, it is possible to invoke the setup.exe later (remember: we copied it to c:\cygwin folder.) and install any additional packages as they become necessary. Here's an example:
 
 
[[Category:Computing]]

Revision as of 11:31, 27 April 2006

  1. Redirect{}