Introduction to Cygwin Operating Environment ICT 106 Fundamentals of Computer Systems Eric Li ICT106_Pract_week 1 1
What s Cygwin? Emulates Unix/Linux environment on a Windows Operating System; A collection of open-source tools and utilities, ported from Unix/Linux; Cygwin/X is an implementation of X Window Server: Unix/Linux graphical applications can be run on Windows. ICT106_Pract_week 1 2
Brief history of Unix: 1960s and 1970s Originally developed by Ken Thompson and Dennis Ritchie in 1960s at AT&T Bell Labs; A time-sharing OS for portability, multitask, and multi-user; Unix was first written in DEC PDP-7 assembly language and re-written in C programming language in 1973; ICT106_Pract_week 1 3
1980s AT&T continued development of commercial Unix: System III and V; TCP/IP network code was first introduced to Unix kernel; Bill Joy, developer of BSD Unix, founded Sun Microsystems and started development of SunOS (now Solaris); In 1984, Microsoft announced its first Unix OS for 16-bit microprocessor - Xenix; ICT106_Pract_week 1 4
1990s Unix wars - between Open Software Foundation and AT&T to set the standard for Unix; AT&T sold Unix to Novell and later Novell sold Unix trademark to X/Open Consortium (now Open Group); Single Unix Specification was drawn by the Open Group in 1998; Development of GNU Linux - a free Unix-like OS; ICT106_Pract_week 1 5
Unix Family [http://en.wikipedia.org/wiki/image:unix.png]
Impacts The most important operating system you may never use Concept of hierarchical file system: arbitrarily nested subdirectory; C programming language; The theory of software modularity and reuse, and so on. ICT106_Pract_week 1 7
The following tutorials of Cygwin are adapted from: http://cplus.about.com/od/compilersandides/l/aa061204a.htm ICT106_Pract_week 1 8
Getting started! Go to Cygwin homepage: www.cygwin.com Click on one of the install Cygwin now icons and download setup.exe ICT106_Pract_week 1 9
Downloading Cygwin Double click setup.exe after download finished
Select installation option Select install from Local Directory
Root install directory
Local package directory
Select packages
Essential packages Make sure the following packages are included: Bash shell: command interpreter gcc: ANSI C compiler gcc-core: C compiler Vi - Unix plain text editor ICT106_Pract_week 1 15
Optional packages GNUmake: programming build tools; CVS: concurrent version system; Emacs: text editor ICT106_Pract_week 1 16
Using Cygwin Double clicking on the icon, or Go to start menu: Programs->Cygwin->Cygwin Bash Shell
Testing the installation
Unix shell Command line for Unix operating systems; Hides the details of the underlying operating system; Use echo $SHELL to determine the current shell. Note that Unix is case sensitive; Command shells: Bourne shell (sh): default Unix shell; Bourne- Again shell (bash): provides a superset of Bourne shell funtionality; C shell (csh): uses similar syntax as the C programming language ICT106_Pract_week 1 19
Basic commands ls mkdir rmdir rm cd chmod gcc show directory create a directory or sub-directory remove directory remove files change current directory changes permissions on file compiles C source files ICT106_Pract_week 1 20
Comparison of Cygwin and DOS commands dir mkdir cd del copy move DOS ls -l mkdir cd rm -iv cp -piv mv -iv Unix ICT106_Pract_week 1 21
Understanding files and directories Tree structure Root directory: /.. means parent directory and. refers to the current directory ICT106_Pract_week 1 22
Directory mapping between Cygwin and Windows Cygwin / /home /cygdrive/c /cygdrive/d /cygdrive/c/program Files /cygdrive/c/program\ Files Windows C:\Cygwin C:\Cygwin\home C: D: C:\Program Files C:\Program Files ICT106_Pract_week 1 23
Managing files Demonstration ICT106_Pract_week 1 24
Programming with Cygwin Text editor: Vi Notepad Emacs ANSI-C compatible compiler; ICT106_Pract_week 1 25
Vi editor Three modes: edit, input and command line; Type i to move from the edit mode to input mode; Hit the escape key to move from input mode to edit mode; ICT106_Pract_week 1 26
Vi commands (1) Edit mode Command h j k l dd p Use move space to left move to next line move to previous line move space to right delete current line paste the copied line at the cursor ICT106_Pract_week 1 27
Vi commands (2) Command line mode Command Use :q quit :q! quit without saving :x save, then quit :w save ICT106_Pract_week 1 28
Example
Notepad Windows basic text editor; Note that a suffix.txt will be attached to the file name as default. Thus, to save a file with All Files file type
Compiling with gcc gcc: ANSI-C compatible; -o: give the name of the executable output
Run HelloWorld program