Computer Systems Org I - Prof. Grishman

Cygwin Notes

For this course, we will be running the gcc C compiler within a Unix-like environment for Windows called Cygwin.  (If you have access to a machine running Linux or another version of Unix, you should be able to use gcc in that environment and will not need Cygwin.)

Cygwin makes use of the Windows directory structure and provides access to some of the Windows facilities.  This makes it flexible for you:  you can learn an absolute minimum of Unix commands (basically, enough to compile and execute C programs) and do everything else in Windows, or learn a bit more of Unix and use more of the capabilities of Cygwin.

The shell

You interact with Cygwin, and run programs, using a command-line interface or "shell" (like the command prompt interface under Windows XP, and the DOS interface under earlier versions of Windows).  Several shells are available;  the default is "bash".  Basically, you run a program under the shell by typing a line of the form

program argument1 argument2 ...

You can quit the shell (and Cygwin) with the exit command.

Basic file utilities

The directory you see when you start Cygwin is underneath Cygwin/home in your Windows directory system.

Listing the files in a directory:  ls

Making a new directory:  mkdir <directory name>

Changing to that directory:  cd <directory name>

Copying a file:  cp <file1> <file2>

Deleting a file:  rm <file>

Deleting a directory:  rmdir <directory name>

Running GCC

To compile a file with gcc:  gcc <file name>
This produces an executable file named a.exe
To run this executable file:  ./a.exe

Editing a file

To use the Windows notepad editor:  notepad <file name>

There are lots of other editors available under Cygwin, if you choose to download them (none are downloaded by default), including nano (the simplest), vim (the oldest), and emacs (the most elaborate).